WebSocket

Stream expressive dialogue audio over a WebSocket by sending incremental text segments per registered voice. The connection uses Eleven v3 dialogue models only (`model_id` must start with `eleven_v3`). The default model is `eleven_v3_conversational`. ## Session setup - After connecting, the first JSON message **must** include `voices` (voice IDs to register for the session) and credentials if not already sent via headers or query string. - Optional `voice_settings` and `pronunciation_dictionary_locators` are only accepted on the first message. - For `eleven_v3_conversational`, only **one** voice ID may be registered. For `eleven_v3`, you may register up to **10** voices. ## Streaming text - Send `inputs`: an array of `{ "text", "voice_id", "new_turn"? }`. Text for the same turn is buffered until the server has enough context (at least ~40 characters and 8 words), then partial audio chunks are emitted. - Set `new_turn` to `true` (or switch `voice_id`) to finalize the current prosody segment and start a new speaker turn. ## Control messages - `flush`: force generation of any buffered text without closing the socket. - `close_socket`: flush remaining audio, send a final message, and close the connection. - `keep_alive`: reset the **20 second** receive timeout (no generation). ## Authentication Use the `xi-api-key` or `Authorization` header, `single_use_token` query parameter, or include `xi_api_key`, `authorization`, or `single_use_token` in the first message body (same pattern as [Text to Speech WebSocket](/docs/api-reference/text-to-speech/v-1-text-to-speech-voice-id-stream-input)). Anonymous sessions are rejected. For non-streaming dialogue over HTTP, see [Create dialogue](/docs/api-reference/text-to-dialogue/convert) and [Stream dialogue](/docs/api-reference/text-to-dialogue/stream).