How to Use Agents
Create and manage intelligent AI assistants.
Agents allow you to create, manage, and interact with intelligent AI assistants. Follow the example below to create a simple agent and start speaking with it.
When you run the example, the agent will greet you with “Hi, how can I help you today?”.
Your spoken input is then converted into text by a speech recognition system.
The prompt
you set above is used as the system prompt for a GPT-4o
model, which generates the
responses.
These responses are then converted to audio using Neuphonic’s TTS and played back to you.
You can keep the conversation going for as long as you want!
Editing the Callback
The Agent
interface described above utilizes a WebSocket connection to facilitate real-time audio
streaming between your microphone and the server.
The server processes this audio and sends back responses, which can be categorized into the following
types:
This message contains the text transcription of your spoken input. It is sent by the server once the speech recognition system detects a pause long enough to consider your turn complete. You will receive one of these messages for each turn in the conversation.
The Agent
class, by default, plays audio_response
messages and prints llm_response
and
user_transcript
messages to the console. To customize this behavior, you can attach a custom event handler
as shown below:
View Agents
To retrieve a list of all your existing agents
The previous response does not include prompt
and greeting
because they can be quite lengthy,
especially for complex agents with extensive system prompts.
The following request will return all details for the specified agent_id
.
More Examples
To see more examples with our Python SDK, head over to the GitHub repo agents examples section.