Skip to content

Live WebSocket

The url of POST /v2/live. Send the audio as binary frames, or as audio_chunk messages; send finalize when your own VAD heard the speaker stop (the open utterance is sent as a final now, the session stays open), keep_alive every few seconds while you send no audio (a pause on hold: the session stays open, billed as session time), session_config to change its settings (language, vocabulary, prompt, add-ons) while it runs, and stop_recording when done. The server sends the messages below, then closes the connection.

Connect

Create the session with POST /v2/live, then open its url. The URL carries a single-use token, valid 60 seconds: create the session on your server and hand only the URL to browsers or phones, your API key never leaves your server. Reconnecting to the same URL after a dropped connection resumes the session (Reconnections).

Whole programs, with the SDKs and without: Quickstart. Try it with your microphone on the Playground.

Send

Audio as binary frames: raw samples in the session's encoding, little-endian, channels interleaved, any size (100 ms is typical). Or as JSON:

audio_chunk

Audio, as JSON. Binary frames of raw audio are accepted too, and cost a third less.

  • type "audio_chunk" required
  • data object required
    1 fields
    • chunk string required

      Audio, base64-encoded, in the session's encoding.

{"type":"audio_chunk","data":{"chunk":"string"}}

stop_recording

No more audio: the server sends the last finals, the post-processing results, then ends the session.

  • type "stop_recording" required
{"type":"stop_recording"}

finalize

The speaker stopped (your own VAD heard it): the open utterance is sent as a final now, without waiting for the server's endpointing, and the session stays open. Answered by a finalize message on each channel.

  • type "finalize" required
{"type":"finalize"}

keep_alive

A pause with no audio (a call on hold, a muted participant, a voice agent speaking): send one every 5 to 30 seconds and the session stays open, its inference ready, instead of stopping after 60 seconds without audio; up to the cluster's longest pause (an hour by default). The pause is billed as session time. Never answered.

  • type "keep_alive" required
{"type":"keep_alive"}

session_config

Change the session's settings while it runs: data is a part of the init body (same names, same values), merged over the settings in force (an object key by key, null unsets a setting). Every setting may change but the audio format, model, callback, callback_config, messages_config, custom_metadata, finalization and speaker identification. The new settings apply from the last final: the utterance in progress is transcribed again with them. Answered by a session_config message.

  • type "session_config" required
  • data object required

    The settings to change, as in the init body.

{"type":"session_config","data":{"language_config":{"languages":["fr"]}}}

Receive

JSON messages, each with a type. messages_config in the init body chooses which ones come; the same messages can go to your callback.

typewhat
start_recording The session is ready: audio may be sent (messages_config.receive_lifecycle_events).
transcript A partial (receive_partial_transcripts) or final (receive_final_transcripts) transcript.
speech_start Speech started on a channel (receive_speech_events).
speech_end Speech ended on a channel (receive_speech_events).
named_entity_recognition The entities of a final, right after it (receive_realtime_processing_events).
pii The personal data redacted in a final, right after it (with pii; on the WebSocket only).
sentiment_analysis The sentiment of a final, right after it (receive_realtime_processing_events).
translation One final translated into one target language (receive_realtime_processing_events).
audio_passthrough The session's audio, echoed back with the beeps of the audio redaction (audio_redaction, receive_realtime_processing_events): one message per packet the client sent, in its own encoding and rate, so it can play back what the far end should hear.
language_detection The language spoken, once the engine knows it, on a session whose model follows the language spoken (receive_realtime_processing_events).
end_of_turn The speaker finished their turn (end_of_turn): a voice agent may answer.
eager_end_of_turn The speaker has probably finished (end_of_turn.eager_eot_threshold): a voice agent may start preparing its answer. An end_of_turn confirms it, or a turn_resumed cancels it.
turn_resumed The speaker went on after an eager_end_of_turn: drop the answer prepared on it.
hold The speaker paused but is still dictating (an address, an email, a phone number, an amount): the end of turn is kept back and the engine keeps listening (end_of_turn).
speculation The verdict of a speculative LLM turn, right after the final it is about (with end_of_turn.speculation; receive_realtime_processing_events). Sent on a keep too.
audio_chunk Audio transcribed: a client may drop it from its resend buffer (receive_acknowledgments).
stop_recording The answer to stop_recording (receive_acknowledgments).
finalize The answer to the client's finalize, one per channel, always sent on the socket.
session_config The answer to the client's session_config (receive_acknowledgments).
end_recording No more audio is accepted (receive_lifecycle_events).
post_transcript The whole session's transcript, after end_recording (receive_post_processing_events).
post_summarization The session's summary, after post_transcript (post_processing.summarization, receive_post_processing_events).
post_final_transcript The session's result, the same as GET /v2/live/{id}'s (receive_post_processing_events).
end_session The last message: the server closes the WebSocket after it (receive_lifecycle_events).
error Something failed during the session (receive_errors).

Close codes

codemeaning
1000The session ended normally.
1008Refused for what the session asks, its reason says why. rejected: …: an option or setting this cluster does not serve (a language, a translation target…): fix the init body and create a new session. Also: audio sent faster than real time.
1011The session failed on our side; its reason says why: create a new session.
1012The service is restarting: reconnect to the same URL to resume.
4401Refused at connect, its reason says why: Invalid or expired token (create a new session), Token already used (the session ended or is served elsewhere), API key revoked, API key expired (its expiry date has passed: use another key), Session resumed elsewhere.
4429The API key already has its max_sessions live sessions open (the reason gives the limit): close one, then connect the same URL again.