Mint a one-use live session token
inference-stt:create or inference-tts:create (matches the selected model)Add-onInferenceRetriesCreates a single-use credential; not replayedAuthenticationMints a token a browser client can connect with, so a long-lived key never reaches your front end. A backend doesn't need one: it can authenticate on either realtime WebSocket directly, with an Inference API key in the Authorization Bearer header.
Requires an Inference API key or an authorized browser session.
The model decides which session you get
A speech-to-text model opens a live transcription socket, which needs inference-stt:create. A text-to-speech model opens a live speech socket, which needs inference-tts:create and an approved voice.
What comes back
A one-use token valid for 30 seconds, and the absolute wss:// URL to connect to with ?token=…. Never place a long-lived key in a WebSocket URL.
Each successful request mints a fresh token. Credit — a character budget for speech, minutes for transcription — is reserved when you connect, not here.
inferenceBearerAuthAuthorizationBearer <token>Use an Inference API key. Access and keys.
application/json- body
model*string1 <= length <= 80language?stringSpeech-to-text models only; a TTS voice decides its own language.
"ar""ar""en""auto"voice?stringRequired for a TTS model, refused for a speech-to-text model. An approved voice from GET /inference/voices.
uuidmax_audio_seconds?integerSpeech-to-text 1–300 (default 60, within the model limit) is the audio the session may accept and is what is reserved. With turn_detection the stream is continuous, so the range is 1–525 (default 300, within the model limit), which ends a real-time stream 15 seconds before the 9-minute session limit with audio_limit_reached; silence counts as audio. Text to speech 1–600 (default 600) is only a cap on the speech produced; it is not what is charged.
1 <= value <= 600max_characters?integerText to speech only. The character budget reserved for the session, clamped to the available balance. Each speak message is charged by its characters; a message that would pass the budget ends the session with character_limit_reached.
1 <= value <= 10000010000turn_detection?Speech to text only. Turn detection lets the model find where each speaker turn starts and ends in a continuous stream, so you do not need your own voice activity detection. Stream audio continuously, silence included. The session sends speech_started and speech_stopped events and one final transcript per turn, with no commit needed; commit still ends the open turn at once. Omit the object to keep the commit-driven session. Unset fields use the model's defaults. Billing is unchanged, on all audio received, silence included. Because the stream is continuous, max_audio_seconds defaults to 300 and accepts up to 525 (within the model limit, so a real-time stream reaches audio_limit_reached before the 9-minute session limit) on a turn-detection session; that is what is reserved.
Mint a one-use live transcription token
application/json- response
token*stringexpires_in*3030kind*stringThe session the token opens, decided by the model.
"stt""tts"url*stringAbsolute wss:// URL of the live socket; append ?token=…
curl -X POST 'https://api.kejue.co/v1/inference/realtime-tokens' \ -H 'Content-Type: application/json' \ -d '{ "model": "string"}'{ "token": "string", "expires_in": 30, "kind": "stt", "url": "string"}