Connect a live transcription session
Opens a WebSocket for live transcription.
Connecting
From a backend, send an Inference API key in the Authorization Bearer header, with the model, language (ar, en or auto; default ar) and max_audio_seconds (1–300; default 60, within the model's limit) query parameters.
From a browser, mint a one-use token with POST /inference/realtime-tokens and connect with the token query parameter alone. Never combine token with Authorization, and never put a long-lived key in a URL. A token is consumed on the first connection attempt.
Sending audio
Send binary PCM16 mono 16 kHz frames, at most 64 KiB each. Send {"type":"commit"} to finalize a segment, or {"type":"finish"} to finalize and close.
Events carry a type of ready, transcript, finished or error. A transcript carries final text — refining interim hypotheses are not supported.
Turn detection
Add turn_detection (semantic or vad) and any td_* settings as query parameters, or set turn_detection on the token request, and the model ends each turn itself: stream audio continuously and skip commit. Each turn is marked by speech_started and speech_stopped, and its final transcript carries end_of_turn (reason, probability, audio_end_ms, silence_ms) and no_speech: true when the turn held no speech. With turn detection on, max_audio_seconds accepts 1–525 (default 300), and pauses are charged like any other audio. Send commit before finish if a turn may still be open. A model without turn detection answers with a turn_detection_unavailable error event.
Limits and close codes
A session lasts at most 9 minutes, and accepted audio is charged, bounded by your reserved minutes and the published limit. A session that receives nothing for 30 seconds before finish gets an idle_timeout error event and closes with 1008.
Close codes are 1000 after finished; 1008 for idle_timeout, audio_limit_reached or invalid_message; 1011 when the model fails.
Credentials, options, permissions and available minutes are all checked before the upgrade, and each direct connection creates a new session.
See live transcription and turn detection.
AuthorizationBearer <token>Use an Inference API key. Access and keys.
token?stringOne-use browser token. Omit when authenticating with an API key.
43 <= length <= 43model?stringPublished STT model alias. Required with API-key authentication; omit when using a token.
language?stringSTT language with API-key authentication. Omit when using a token.
"ar""ar""en""auto"max_audio_seconds?integerAudio reservation cap with API-key authentication. Omit when using a token. 1–300 (default 60) without turn detection; 1–525 (default 300) with turn_detection. Always within the model limit.
1 <= value <= 525turn_detection?stringTurn detection with API-key authentication (see InferenceTurnDetection). The model finds turns in a continuous stream and sends speech_started, speech_stopped and one final transcript per turn. Omit for the commit-driven session; omit when using a token.
"semantic""vad"td_silence_ms?integerSilence before a verdict (semantic) or before the turn ends (vad), in milliseconds. Requires turn_detection. API-key authentication only.
100 <= value <= 5000td_max_silence_ms?integerSemantic backstop in milliseconds; at least td_silence_ms. Requires turn_detection. API-key authentication only.
200 <= value <= 10000td_threshold?numberTurn-model completion probability (semantic). Requires turn_detection. API-key authentication only.
0 <= value <= 1td_min_speech_ms?integerVoice needed before a turn opens, in milliseconds. Requires turn_detection. API-key authentication only.
0 <= value <= 2000td_prefix_padding_ms?integerAudio kept from before the detected start of speech, in milliseconds. Requires turn_detection. API-key authentication only.
0 <= value <= 2000td_vad_threshold?numberSpeech probability above which a frame counts as voice. Requires turn_detection. API-key authentication only.
0 <= value <= 1td_idle_ms?integerEnds an open turn when no audio arrives for this long; 0 turns it off. Requires turn_detection. API-key authentication only.
0 <= value <= 10000td_no_speech_logprob?numberMean token log-probability below which a turn is reported as no speech. Requires turn_detection. API-key authentication only.
-10 <= value <= 0td_incomplete_threshold?numberWith semantic turn detection, an end-of-turn probability below this counts as clearly unfinished and extends the wait by td_incomplete_extend_ms; 0 turns it off. Must not exceed td_threshold. Requires turn_detection. API-key authentication only.
0 <= value <= 1td_incomplete_extend_ms?integerExtra silence allowed after the speaker's last word when the end-of-turn model judges the sentence clearly unfinished. Requires turn_detection. API-key authentication only.
0 <= value <= 10000WebSocket upgraded. Client sends binary PCM16 mono 16 kHz; JSON controls commit or finish. Server events: ready, transcript (final text), finished, error.
curl -X GET 'https://api.kejue.co/v1/inference/audio/transcriptions/realtime'