Messages
API reference
Voice Agent WebSocket API
Connect to the Voice Agent API to run a real-time voice conversation. The client streams PCM16 audio to the server and receives the agent’s spoken response (also PCM16), along with transcripts, tool calls, and lifecycle events.
After the WebSocket opens, send a session.update as your
first message. You have two ways to configure the agent:
- Stored agent. Send
{ "agent_id": "<id>" }as the only field insessionto bind to a reusable agent created via the Agents REST API. The storedsystem_prompt,greeting,tools,input, andoutputare applied server-side. - Inline configuration. Omit
agent_idand sendsystem_prompt,greeting,tools,input, andoutputdirectly. Useful for one-off or fully dynamic agents.
The two modes are mutually exclusive. See Deploy your agent and Inline session configuration for details, or jump to the Voice Agent API overview for the full event flow and a runnable quickstart.
WSS
Messages