跳到导航

WebSocket

The Realtime Translation WebSocket API streams translation audio continuously to a target language given source audio. Currently for enterprise workspaces only.

握手

WSS
/v1/translation/realtime

请求头

xi-api-keystring可选

查询参数

authorizationstring可选
Your authorization bearer token.
target_languagestring必需

Target language as an ISO 639 code (e.g. de, es, fr, zh).

source_languagestring可选

Source language as an ISO 639 code. When omitted the server auto-detects the spoken language.

voice_idstring必需
Voice ID used for the translated speech output.
input_formatany可选
Audio encoding format for realtime translation input.
output_formatany可选
Audio encoding format for realtime translation output.
tts_model_idenum可选默认为 eleven_v4_turbo
TTS model used to synthesize the translated speech.
允许的值:
apply_text_normalizationenum可选默认为 off

This parameter controls text normalization with three modes: ‘auto’, ‘on’, and ‘off’. When set to ‘auto’, the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With ‘on’, text normalization will always be applied, while with ‘off’, it will be skipped.

允许的值:
eagernessenum可选默认为 medium
How eagerly translation starts while the speaker is still talking. 'high' starts translating soonest for the lowest latency. 'low' waits for more of the sentence, giving higher quality translations with more delay.
允许的值:
client_session_idstring可选

Optional client-defined session identifier for tracking purposes.

enable_zrmboolean可选默认为 false

When enable_zrm is set to true, zero retention mode will be used for the request. Sensitive content (transcripts, translations, and TTS text) is not written to application logs or session history. Zero retention mode may only be used by enterprise customers.

发送

inputAudioChunkobject必需
Send a chunk of audio for translation.
OR
endOfStreamobject必需
Signal that the audio stream has ended.

接收

sessionStartedobject必需
Sent by the server when the session is initialized.
OR
statusobject必需
Session lifecycle update indicating the session has started or stopped.
OR
partialTranscriptobject必需
Interim transcription of the source audio.
OR
finalTranscriptobject必需
Final transcription of a segment of source audio.
OR
translationobject必需
Translated text in the target language.
OR
audioobject必需

Base64-encoded audio of the translated speech.

OR
errorobject必需
Error encountered during translation.
OR
Translate Auth Errorobject必需
Authentication failed for the session.
OR
Translate Rate Limited Errorobject必需
The request rate limit was reached.
OR
Translate Queue Overflow Errorobject必需
Audio was sent too frequently and the session was terminated.
OR
Translate Input Errorobject必需

An input message could not be handled; check the message format.

OR
Translate Transcriber Errorobject必需
The transcriber failed to process the audio.
OR
Translate Translation Errorobject必需

Translation failed for a segment; the session continues.

OR
Translate Audio Output Errorobject必需

Audio output for a segment failed or was dropped; the session continues.

OR
Translate Quota Exceeded Errorobject必需

The workspace is out of credits; the session is closed.

OR
Translate Payment Issue Errorobject必需

The workspace has a payment issue or is suspended; the session is closed.

OR
Translate Unaccepted Terms Errorobject必需

The workspace has not accepted terms required for this feature; the session is closed.