Create the URL
Use the ID of a live voice agent in your Karta account:agent_override is best-effort. If its schema is malformed or unsupported, the session is still created with the stored agent configuration and the response includes a warning explaining why the override was ignored.
A successful request returns 201 Created:
201 Created:
Expiry and reconnection
The signed URL:- Expires five minutes after it is created.
- Can open only one WebSocket connection.
- Cannot be reused when reconnecting.
- After the connection opens successfully, the conversation can continue beyond five minutes.
Connect to the session
Open the
signed_url returned by the session request. Use the URL exactly as returned.
Audio format
Use the audio format below to send user audio and decode agent audio.Connection flow
- Open the signed WebSocket URL.
- Send one conversation initiation request.
- Wait for the conversation metadata response.
- Send user audio requests.
- Play agent audio responses in the order received.
- Close the WebSocket to end the conversation, or handle a server-initiated conversation end.
Client-to-server messages
Conversation initiation
Send this once after the WebSocket opens:agent_override.language_config.primary_language can select any language
already configured as the agent’s primary or secondary language. The selected
language also determines the welcome message from languageDefaultsConfig.
When provided during both session creation and conversation initiation, the
session-creation override wins.
An invalid override in the conversation-initiation message is ignored and the
conversation continues with the stored agent configuration.
Contextual update
Once the conversation is active, add or replace LLM dynamic variables without interrupting it:
At least one value inside
contextual_update_values is required. The update is
asynchronous and does not produce a direct server response.
User audio
Send this message while the user is speaking:
Use chunks between 20 and 100 milliseconds:
Server-to-client messages
Conversation metadata
Sent after the conversation initiation request:Agent audio
Sent whenever the agent produces audio:
Decode
audio_event.audio_base_64, queue each chunk, and play chunks in the
order received without overlapping them.
Conversation ended
Sent after the final agent audio when Karta ends the underlying agent session, including after an inactivity timeout:1000; clients may also close it
immediately after handling the message.
WebSocket close codes
Never reconnect with the same signed URL.