本文介紹千問即時語音和音視頻翻譯 API 的服務端事件,包括事件類型、參數和範例。
相關文件:即時語音/音視頻翻譯-千問
說明本頁為 Qwen-LiveTranslate-Realtime 的事件參考,事件定義以 WebSocket 接入為基礎。AOQ、WebRTC 透過各自的資料通道收發模型事件,媒體透過媒體軌道傳輸。請先閱讀WebSocket 接入、WebRTC 接入或AOQ 接入。
WebSocket SDK 用法請參見 Python SDK與 Java SDK。模型與協議選擇請參見概述。
error
伺服器返回的錯誤資訊。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 error。
errorobject錯誤的詳細資訊。
屬性
typestring錯誤類型。
codestring錯誤碼。
messagestring錯誤資訊。
paramstring與錯誤相關的參數,如 session.modalities。
{
"event_id": "event_RoUu4T8yExPMI37GKwaOC",
"type": "error",
"error": {
"type": "invalid_request_error",
"code": "invalid_value",
"message": "Invalid modalities: ['audio']. Supported combinations are: ['text'] and ['audio', 'text'].",
"param": "session.modalities"
}
}
session.created
用戶端建立連線後,伺服器首先返回此事件,包含預設的工作階段配置。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 session.created。
sessionobject工作階段配置。
屬性
idstring工作階段的唯一識別碼。
objectstring固定為 realtime.session。
modelstring使用的模型。
input_modalitiesarray適用於 qwen3.8-livetranslate-flash-realtime。輸入模態,例如 ["audio"]。
output_modalitiesarray適用於 qwen3.8-livetranslate-flash-realtime。輸出模態為 ["text"] 或 ["text", "audio"]。
audioobject適用於 qwen3.8-livetranslate-flash-realtime。音訊輸入與輸出設定。
屬性
inputobject屬性
formatobject輸入格式。type 預設為 pcm,sample_rate 預設為 16000(Hz)。
turn_detectionobject斷句設定。預設值:type 為 speaker_detection,threshold 為 0.5,silence_duration_ms 為 1000。
outputobject屬性
formatobject工作階段的預設輸出格式。type 為 pcm,sample_rate 為 24000 Hz。
voicestring輸出音色。預設為 Tina。
modalitiesarray適用於 qwen3.5-livetranslate-flash-realtime 等模型。
模型的輸出模態設定。
voicestring適用於 qwen3.5-livetranslate-flash-realtime 等模型。
模型產生音訊的音色。
input_audio_formatstring適用於 qwen3.5-livetranslate-flash-realtime 等模型。
輸入音訊格式,預設為 pcm。
sample_rateinteger適用於 qwen3.5-livetranslate-flash-realtime 等模型。
輸入音訊的採樣率,單位為 Hz。
output_audio_formatstring適用於 qwen3.5-livetranslate-flash-realtime 等模型。
輸出音訊格式,預設為 pcm。
turn_detectionobject適用於 qwen3.5-livetranslate-flash-realtime 等模型。
VAD(語音活動檢測)配置。
translationobject(可選)翻譯配置。
屬性
languagestring(可選)翻譯的目標語言。
qwen3.8-livetranslate-flash-realtime
適用於 qwen3.8-livetranslate-flash-realtime。
{
"event_id": "event_example",
"type": "session.created",
"session": {
"id": "sess_example",
"object": "realtime.session",
"model": "qwen3.8-livetranslate-flash-realtime",
"input_modalities": [
"audio"
],
"output_modalities": [
"text",
"audio"
],
"audio": {
"input": {
"format": {
"type": "pcm",
"sample_rate": 16000
},
"turn_detection": {
"type": "speaker_detection",
"threshold": 0.5,
"silence_duration_ms": 1000
}
},
"output": {
"format": {
"type": "pcm",
"sample_rate": 24000
},
"voice": "Tina"
}
},
"translation": {
"language": "en"
}
}
}
qwen3.5-livetranslate-flash-realtime
qwen3.5-livetranslate-flash-realtime 的範例:
{
"event_id": "event_QxBGpjBDmDDQQWDtrqBKB",
"type": "session.created",
"session": {
"id": "sess_OozZ1vtbPt2muDflHODIH",
"object": "realtime.session",
"model": "qwen3.5-livetranslate-flash-realtime",
"modalities": [
"text",
"audio"
],
"voice": "Cherry",
"input_audio_format": "pcm",
"sample_rate": 16000,
"output_audio_format": "pcm",
"turn_detection": {
"type": "server_vad",
"threshold": 0.2,
"silence_duration_ms": 1000
},
"translation": {
"language": "en",
"corpus": {
"phrases": {
"人工智能": "Artificial Intelligence",
"机器学习": "Machine Learning"
}
}
}
}
}
session.updated
session.update 請求處理成功後返回此事件;若請求失敗,則改返回 error 事件。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 session.updated。
sessionobject工作階段配置。
屬性
idstring工作階段的唯一識別碼。
objectstring固定為 realtime.session。
modelstring使用的模型。
input_modalitiesarray適用於 qwen3.8-livetranslate-flash-realtime。輸入模態,例如 ["audio"]。
output_modalitiesarray適用於 qwen3.8-livetranslate-flash-realtime。輸出模態為 ["text"] 或 ["text", "audio"]。
audioobject適用於 qwen3.8-livetranslate-flash-realtime。音訊輸入與輸出設定。
屬性
inputobject屬性
formatobject輸入格式。type 預設為 pcm,sample_rate 預設為 16000(Hz)。
turn_detectionobject斷句設定。預設值:type 為 speaker_detection,threshold 為 0.5,silence_duration_ms 為 1000。
outputobject屬性
formatobject工作階段的輸出格式設定。請將來自 response.audio.delta 的翻譯音訊以 24 kHz PCM 播放。
voicestring輸出音色。預設為 Tina。
modalitiesarray適用於 qwen3.5-livetranslate-flash-realtime 等模型。
模型的輸出模態設定。
voicestring適用於 qwen3.5-livetranslate-flash-realtime 等模型。
模型產生音訊的音色。
sample_rateinteger(可選)適用於 qwen3.5-livetranslate-flash-realtime 等模型。
輸入音訊的採樣率,單位為 Hz。
input_audio_formatstring適用於 qwen3.5-livetranslate-flash-realtime 等模型。
輸入音訊格式,固定為 pcm。
output_audio_formatstring適用於 qwen3.5-livetranslate-flash-realtime 等模型。
輸出音訊格式,固定為 pcm。
input_audio_transcriptionobject適用於 qwen3.5-livetranslate-flash-realtime 等模型。
輸入音訊轉錄配置。僅在工作階段中配置了 input_audio_transcription.model 參數時返回。
屬性
modelstring語音辨識模型。
languagestring已配置的語音辨識語言。
turn_detectionobject適用於 qwen3.5-livetranslate-flash-realtime 等模型。
VAD(語音活動檢測)配置。Manual 模式下(用戶端在 session.update 中將該參數設為 null 時)不返回此欄位。
屬性
typestringVAD 類型,固定為 server_vad。
thresholdfloatVAD 檢測靈敏度。
prefix_padding_msinteger語音開始前保留的音訊時長(毫秒),避免遺失語音起始部分。
silence_duration_msinteger語音結束後需保持靜音的最短時長(毫秒),超過該時長即判定語音結束。
create_responsebooleanVAD 檢測到語音結束後,是否自動觸發翻譯回應。
interrupt_responsebooleanVAD 檢測到新一輪語音開始時,是否中斷當前正在產生的翻譯回應。
translationobject(可選)翻譯配置。
屬性
languagestring(可選)翻譯的目標語言。
corpusobject(可選)自訂術語配置,用於提升特定領域詞彙的翻譯準確性。
屬性
phrasesobject(可選)原始語言詞彙到目標語言譯文的映射。
enable_voice_cloneboolean是否啟用聲音複刻。
voice_clone_optionsobject聲音複刻控制參數,僅在 enable_voice_clone 為 true 時返回。
屬性
frequencystring聲音複刻頻率。
qwen3.8-livetranslate-flash-realtime
適用於 qwen3.8-livetranslate-flash-realtime。
{
"event_id": "event_example",
"type": "session.updated",
"session": {
"id": "sess_example",
"object": "realtime.session",
"model": "qwen3.8-livetranslate-flash-realtime",
"input_modalities": [
"audio"
],
"output_modalities": [
"text",
"audio"
],
"audio": {
"input": {
"format": {
"type": "pcm",
"sample_rate": 16000
},
"turn_detection": {
"type": "speaker_detection",
"threshold": 0.5,
"silence_duration_ms": 1000
}
},
"output": {
"format": {
"type": "pcm",
"sample_rate": 24000
},
"voice": "Tina"
}
},
"translation": {
"language": "en"
}
}
}
qwen3.5-livetranslate-flash-realtime
qwen3.5-livetranslate-flash-realtime 的範例:
{
"event_id": "event_QxBGpjBDmDDQQWDtrqBKB",
"type": "session.updated",
"session": {
"id": "sess_OozZ1vtbPt2muDflHODIH",
"object": "realtime.session",
"model": "qwen3.5-livetranslate-flash-realtime",
"modalities": [
"text",
"audio"
],
"voice": "Ethan",
"sample_rate": 16000,
"input_audio_format": "pcm",
"output_audio_format": "pcm",
"input_audio_transcription": {
"model": "qwen3-asr-flash-realtime",
"language": "zh"
},
"turn_detection": {
"type": "server_vad",
"threshold": 0.2,
"prefix_padding_ms": 300,
"silence_duration_ms": 1000,
"create_response": true,
"interrupt_response": true
},
"translation": {
"language": "en",
"corpus": {
"phrases": {
"人工智能": "Artificial Intelligence",
"机器学习": "Machine Learning"
}
}
},
"enable_voice_clone": true,
"voice_clone_options": {
"frequency": "once"
}
}
}
session.finished
工作階段結束,所有音訊翻譯已完成。
此事件在用戶端發送 session.finish 後返回。用戶端收到此事件後,如需播放剩餘譯音,應先完成本地播放,再主動斷開連線。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 session.finished。
{
"event_id": "event_xxx",
"type": "session.finished"
}
response.created
伺服器產生新的模型回應時返回此事件。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.created。
responseobject回應物件。
屬性
idstring回應的唯一識別碼。
conversation_idstring當前工作階段的唯一識別碼。
objectstring物件類型,此事件下固定為 realtime.response。
statusstring回應狀態,取值範圍:
completedfailedin_progressincomplete
modalitiesarray回應的模態。
voicestring產生音訊的音色。
output_audio_formatstring輸出音訊格式。
outputarray此事件下目前為空。
{
"event_id": "event_L8hHVI5jYis6BzAjnPWJh",
"type": "response.created",
"response": {
"id": "resp_P79OOMs8LnrXVpiIHUCKR",
"object": "realtime.response",
"conversation_id": "conv_UFClXtYkRkFXrs48y8pmK",
"status": "in_progress",
"modalities": [
"text",
"audio"
],
"voice": "Cherry",
"output_audio_format": "pcm16",
"output": []
}
}
response.done
回應產生完成後返回此事件。包含除原始音訊資料外的全部輸出項。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.done。
responseobject回應物件。
屬性
idstring回應的唯一識別碼。
conversation_idstring當前工作階段的唯一識別碼。
objectstring物件類型,此事件下固定為 realtime.response。
statusstring回應的狀態。
modalitiesarray回應的模態。
voicestring模型產生音訊所使用的音色。
output_audio_formatstring輸出音訊格式。
outputobject回應的輸出。
屬性
idstring回應輸出的唯一識別碼。
typestring輸出項的類型,目前固定為 message。
objectstring輸出項的物件類型,目前固定為 realtime.item。
statusstring輸出項的狀態。
rolestring輸出項的角色。
contentarray輸出項的內容。
屬性
typestring輸出內容的類型。輸出為純文字時為 text;輸出包含音訊時為 audio。
textstring輸出的文字內容。
transcriptstring音訊內容轉錄為文字後的內容。
usageobject工作階段截至目前回應的累計 Token 用量。每次 response.done 都會返回當前累計值。統計整個工作階段的用量時,取最後一次的 usage,無需將各次結果相加。
屬性
total_tokensinteger輸入與輸出 Token 總數,即 input_tokens 與 output_tokens 之和。
input_tokensinteger輸入 Token 數。
output_tokensinteger輸出 Token 數。
input_tokens_detailsobject輸入 Token 的分類統計。
屬性
text_tokensinteger模型固定系統提示詞中的文字 Token 數,不計費。
audio_tokensinteger輸入音訊 Token 數。
video_tokensinteger輸入圖片 Token 數,按圖片輸入計費。
output_tokens_detailsobject輸出 Token 的分類統計。
屬性
text_tokensinteger輸出文字 Token 數。
audio_tokensinteger輸出音訊 Token 數。
{
"event_id": "event_CNea8oXNipVanSg2VIzkO",
"type": "response.done",
"response": {
"id": "resp_TfhYTqej692vsGA2jNEtH",
"object": "realtime.response",
"conversation_id": "conv_ZtyLfKVm8XqLwYRlsuDih",
"status": "completed",
"modalities": [
"text",
"audio"
],
"voice": "Cherry",
"output_audio_format": "pcm16",
"output": [
{
"id": "item_MKtkMwN9RtcyE9eJShyWy",
"object": "realtime.item",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "audio",
"transcript": "Hello? "
}
]
}
],
"usage": {
"total_tokens": 56,
"input_tokens": 47,
"output_tokens": 9,
"input_tokens_details": {
"text_tokens": 20,
"audio_tokens": 27
},
"output_tokens_details": {
"text_tokens": 2,
"audio_tokens": 7
}
}
}
}
response.text.delta
適用於 qwen3.8-livetranslate-flash-realtime。為純文字輸出返回新的翻譯片段。
event_idstring事件唯一識別碼。
typestringresponse.text.delta.
response_idstring回應 ID。
item_idstring訊息 ID。
output_indexinteger輸出項索引。
content_indexinteger內容部分索引。
deltastring新的文字片段。請按到達順序追加片段,不要替換先前收到的文字。
{
"event_id": "event_example",
"type": "response.text.delta",
"response_id": "resp_example",
"item_id": "item_example",
"output_index": 0,
"content_index": 0,
"delta": "Hello"
}
response.text.text
適用於 qwen3.5-livetranslate-flash-realtime 等模型。qwen3.8-livetranslate-flash-realtime 請改用 response.text.delta。
當輸出模態僅包含文字,且模型增量產生新文字時,返回此事件。
event_idstring事件的唯一識別碼。
typestring事件類型,固定為 response.text.text。
textstring返回的增量文字。
response_idstring回應的 ID。
item_idstring訊息項的唯一識別碼。
output_indexinteger目前固定為 0。
content_indexinteger目前固定為 0。
stashstring模型產生的臨時文字。將 stash 與當前 text 拼接後構成臨時結果。系統會透過 response.text.text 事件持續更新 text 和 stash,直至收到 response.text.done 事件,此時可透過 text 欄位取得完整的最終文字。
{
"event_id": "event_B1lIeyOXR7qJMEExbqtTG",
"type": "response.text.text",
"response_id": "resp_B1lIdtjF4Noqpn5NOjznj",
"item_id": "item_B1lIdJsAJlJiFs8ztWpJt",
"output_index": 0,
"content_index": 0,
"text": "How are",
"stash": " you today?"
}
response.text.done
當純文字輸出的文字產生結束時返回此事件;回應被中斷、不完整或取消時也會返回。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.text.done。
response_idstring回應的唯一識別碼。
item_idstring訊息項的唯一識別碼。
output_indexinteger目前固定為 0。
content_indexinteger目前固定為 0。
textstring模型輸出的完整文字。
{
"event_id": "event_B1lIeE2Nac33zn5V7h2mm",
"type": "response.text.done",
"response_id": "resp_B1lIdtjF4Noqpn5NOjznj",
"item_id": "item_B1lIdJsAJlJiFs8ztWpJt",
"output_index": 0,
"content_index": 0,
"text": "How can I assist you today?"
}
response.audio.delta
WebSocket 接入時,當輸出模態包含音訊,且模型增量產生新的音訊資料時,伺服器返回此事件。
event_idstring事件的唯一識別碼。
typestring事件類型,固定為 response.audio.delta。
response_idstring回應的唯一識別碼。
item_idstring訊息項的唯一識別碼。
output_indexinteger固定為 0。
content_indexinteger固定為 0。
deltastring模型增量輸出的音訊資料,使用 Base64 編碼。
{
"event_id": "event_B1osWMZBtrEQbiIwW0qHQ",
"type": "response.audio.delta",
"response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
"item_id": "item_OFaPGtzfWCPyGzxnuEX9i",
"output_index": 0,
"content_index": 0,
"delta": "UklGRnoGAABXQVZFZm10IBAAAAAB..."
}
response.audio.done
音訊產生完成後返回此事件;回應被中斷、不完整或取消時也會返回。不包含完整音訊資料。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.audio.done。
response_idstring回應的唯一識別碼。
item_idstring訊息項的唯一識別碼。
output_indexinteger固定為 0。
content_indexinteger固定為 0。
{
"event_id": "event_B1osWMWoDRYyITDyNYcBu",
"type": "response.audio.done",
"response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
"item_id": "item_OFaPGtzfWCPyGzxnuEX9i",
"output_index": 0,
"content_index": 0
}
input_audio_buffer.speech_started
伺服器端 VAD(語音活動檢測)檢測到使用者開始說話時返回此事件。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 input_audio_buffer.speech_started。
audio_start_msinteger檢測到語音開始的時間點(毫秒),相對於音訊流開頭的位移量。
item_idstring關聯訊息項的唯一識別碼。
speaker_idinteger適用於 qwen3.8-livetranslate-flash-realtime。啟用 speaker_detection 時返回的說話人識別碼。使用本事件的 item_id 將說話人與轉錄結果關聯,使用翻譯項的 previous_item_id 將其與翻譯關聯。
{
"event_id": "event_xxx",
"type": "input_audio_buffer.speech_started",
"audio_start_ms": 568,
"item_id": "item_xxx"
}
input_audio_buffer.speech_stopped
伺服器端 VAD 檢測到使用者停止說話時返回此事件,標誌本輪語音輸入結束。由於翻譯回應與流式語音輸入同步產生,實際的翻譯回應可能已在語音輸入過程中開始,無需等待此事件。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 input_audio_buffer.speech_stopped。
audio_end_msinteger檢測到語音結束的時間點(毫秒),相對於音訊流開頭的位移量。
item_idstring關聯訊息項的唯一識別碼。
{
"event_id": "event_xxx",
"type": "input_audio_buffer.speech_stopped",
"audio_end_ms": 3900,
"item_id": "item_xxx"
}
input_audio_buffer.committed
Manual 模式(turn_detection 為 null)下,用戶端發送 input_audio_buffer.commit 事件後,伺服器返回此事件進行確認,並自動開始產生翻譯回應。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 input_audio_buffer.committed。
{
"event_id": "event_xxx",
"type": "input_audio_buffer.committed"
}
input_audio_buffer.cleared
用戶端發送 input_audio_buffer.clear 事件後,伺服器返回此事件進行確認,表示已清空緩衝區中尚未提交的音訊資料。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 input_audio_buffer.cleared。
{
"event_id": "event_xxx",
"type": "input_audio_buffer.cleared"
}
conversation.item.created
對話中建立新的訊息項時返回此事件。以下情境會觸發此事件:
- 伺服器開始產生翻譯回應時,建立對應的 assistant 訊息項(此時
content為空陣列,內容隨流式回應逐步填充)。 - Manual 模式下,用戶端發送
input_audio_buffer.commit事件後,伺服器會額外建立一個對應使用者輸入音訊的訊息項(content包含{"type": "input_audio"})。
對於同一個 VAD 片段,伺服器會分別建立語音辨識結果和翻譯結果的訊息項。語音辨識結果的 item.id 與翻譯結果事件中的 previous_item_id 相同。可使用這些值關聯並同時展示原文與譯文。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 conversation.item.created。
previous_item_idstring前一個訊息項的唯一識別碼。對於翻譯結果事件,該值與同一 VAD 片段語音辨識結果訊息項的 item.id 相同。
itemobject訊息項資訊。
屬性
idstring訊息項的唯一識別碼。
typestring固定為 message。
objectstring固定為 realtime.item。
statusstring訊息項的狀態。
rolestring訊息的角色,取值為 assistant 或 user。
contentarray訊息的內容。回應剛建立時為空陣列,隨流式回應逐步填充;Manual 模式下由 commit 建立的使用者訊息項中則包含 {"type": "input_audio"}。
{
"event_id": "event_xxx",
"type": "conversation.item.created",
"previous_item_id": "item_asr_xxx",
"item": {
"id": "item_translation_xxx",
"object": "realtime.item",
"type": "message",
"status": "in_progress",
"role": "assistant",
"content": []
}
}
conversation.item.input_audio_transcription.delta
適用於 qwen3.8-livetranslate-flash-realtime。返回輸入音訊的原始語言轉錄增量。
event_idstring事件唯一識別碼。
typestringconversation.item.input_audio_transcription.delta.
item_idstring訊息 ID。
content_indexinteger內容部分索引。
deltastring新的文字片段。請按到達順序追加片段,不要替換先前收到的文字。
{
"event_id": "event_example",
"type": "conversation.item.input_audio_transcription.delta",
"item_id": "item_example",
"content_index": 0,
"delta": "Hello"
}
conversation.item.input_audio_transcription.text
適用於 qwen3.5-livetranslate-flash-realtime 等模型。qwen3.8-livetranslate-flash-realtime 請改用 conversation.item.input_audio_transcription.delta。
配置了 input_audio_transcription.model 時,伺服器會以原始語言流式返回語音辨識結果。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 conversation.item.input_audio_transcription.text。
item_idstring訊息項的唯一識別碼。
content_indexinteger目前固定為 0。
textstring已確認的辨識文字。
stashstring待確認的辨識文字(可能會被後續事件修正)。
languagestring檢測到的原始語言。
emotionstring辨識音訊檢測到的情感。支援的情感如下:
surprised:驚訝neutral:平靜happy:愉快sad:悲傷disgusted:厭惡angry:憤怒fearful:恐懼
{
"event_id": "event_xxx",
"type": "conversation.item.input_audio_transcription.text",
"item_id": "item_xxx",
"content_index": 0,
"text": "",
"stash": "The weather is really nice today",
"language": "zh",
"emotion": "neutral"
}
conversation.item.input_audio_transcription.completed
配置了 input_audio_transcription.model 時,語音辨識完成後返回此事件,包含最終的完整辨識結果。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 conversation.item.input_audio_transcription.completed。
item_idstring訊息項的唯一識別碼。
content_indexinteger目前固定為 0。
transcriptstring以原始語言表示的完整語音辨識結果。
languagestring檢測到的原始語言。
emotionstring辨識音訊檢測到的情感。支援的情感:
surprised:驚訝neutral:平靜happy:愉快sad:悲傷disgusted:厭惡angry:憤怒fearful:恐懼
{
"event_id": "event_xxx",
"type": "conversation.item.input_audio_transcription.completed",
"item_id": "item_xxx",
"content_index": 0,
"transcript": "What a beautiful day! Let's go for a walk in the park together.",
"language": "en",
"emotion": ""
}
conversation.item.input_audio_transcription.failed
收到音訊輸入但語音辨識失敗時返回此事件。此事件與其他 error 事件分開處理,便於用戶端識別相關的具體項目。
typestring事件類型,固定為 conversation.item.input_audio_transcription.failed。
item_idstring關聯對話項的 ID。
content_indexinteger包含音訊的內容部分索引。
errorobject屬性
codestring錯誤碼。
messagestring錯誤資訊。
{
"event_id": "event_xxx",
"type": "conversation.item.input_audio_transcription.failed",
"item_id": "item_xxx",
"content_index": 0,
"error": {
"code": "xxx",
"message": "xxx",
"param": "xxx"
}
}
response.audio_transcript.delta
適用於 qwen3.8-livetranslate-flash-realtime。為文字和音訊輸出返回新的翻譯片段。
event_idstring事件唯一識別碼。
typestringresponse.audio_transcript.delta.
response_idstring回應 ID。
item_idstring訊息 ID。
output_indexinteger輸出項索引。
content_indexinteger內容部分索引。
deltastring新的文字片段。請按到達順序追加片段,不要替換先前收到的文字。
{
"event_id": "event_example",
"type": "response.audio_transcript.delta",
"response_id": "resp_example",
"item_id": "item_example",
"output_index": 0,
"content_index": 0,
"delta": "Hello"
}
response.audio_transcript.text
適用於 qwen3.5-livetranslate-flash-realtime 等模型。qwen3.8-livetranslate-flash-realtime 請改用 response.audio_transcript.delta。
當輸出包含音訊時返回此事件,用於展示即時翻譯內容。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.audio_transcript.text。
response_idstring回應的唯一識別碼。
item_idstring訊息項的唯一識別碼。
output_indexinteger目前固定為 0。
content_indexinteger目前固定為 0。
textstring已確認的翻譯文字片段。
stashstring臨時翻譯文字,與當前 text 拼接後構成臨時翻譯結果。系統會透過 response.audio_transcript.text 事件持續更新 text 和 stash,直至收到 response.audio_transcript.done 事件,此時可透過 transcript 欄位取得完整的最終翻譯文字。
{
"event_id": "event_xxx",
"type": "response.audio_transcript.text",
"response_id": "resp_xxx",
"item_id": "item_xxx",
"output_index": 0,
"content_index": 0,
"text": "Hello,",
"stash": " who are you?"
}
response.audio_transcript.done
當輸出包含音訊且文字產生結束時,返回此事件。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.audio_transcript.done。
response_idstring回應的唯一識別碼。
item_idstring訊息項的唯一識別碼。
output_indexinteger目前固定為 0。
content_indexinteger目前固定為 0。
transcriptstring完整的文字。
{
"event_id": "event_VN4Q4GJugLcc1S23viW8E",
"type": "response.audio_transcript.done",
"response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
"item_id": "item_JvJauNH2CTXb1D9WV6pD4",
"output_index": 0,
"content_index": 0,
"transcript": "How can I assist you today?"
}
response.output_item.added
回應產生過程中新增輸出項時返回此事件。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.output_item.added。
response_idstring回應的唯一識別碼。
output_indexinteger目前固定為 0。
itemobject輸出項資訊。
屬性
idstring輸出項的唯一識別碼。
typestring固定為 message。
objectstring固定為 realtime.item。
statusstring輸出項的狀態。
rolestring訊息的角色。
contentstring訊息的內容。
{
"event_id": "event_B4O5yPt3Gjnjy5eYH3plG",
"type": "response.output_item.added",
"response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
"output_index": 0,
"item": {
"id": "item_OFaPGtzfWCPyGzxnuEX9i",
"object": "realtime.item",
"type": "message",
"status": "in_progress",
"role": "assistant",
"content": []
}
}
response.output_item.done
輸出項輸出完成時返回此事件。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.output_item.done。
response_idstring回應的唯一識別碼。
output_indexinteger目前固定為 0。
itemobject輸出項資訊。
屬性
idstring輸出項的唯一識別碼。
objectstring固定為 realtime.item。
typestring固定為 message。
statusstring輸出項的狀態。
rolestring發送訊息的角色。
contentstring訊息的內容。
{
"event_id": "event_XkiwbYTBC9Wcdwy6uYJ2G",
"type": "response.output_item.done",
"response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
"output_index": 0,
"item": {
"id": "item_JvJauNH2CTXb1D9WV6pD4",
"object": "realtime.item",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "audio",
"text": "Hello, I am a large language model developed by Alibaba Cloud. My name is Qwen. How can I help you?"
}
]
}
}
response.content_part.added
新增內容部分時返回此事件。
event_idstring事件的唯一 ID。
typestring事件類型,固定為 response.content_part.added。
response_idstring回應的唯一 ID。
item_idstring訊息項的唯一 ID。
output_indexinteger固定為 0。
content_indexinteger固定為 0。
partobject輸出項資訊。
屬性
typestring內容部分的類型。
textstring內容部分的文字。
{
"event_id": "event_J2UixwYKZsXg7c9YXZetL",
"type": "response.content_part.added",
"response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
"item_id": "item_OFaPGtzfWCPyGzxnuEX9i",
"output_index": 0,
"content_index": 0,
"part": {
"type": "audio",
"text": ""
}
}
response.content_part.done
內容部分輸出完成時返回此事件。
event_idstring本次事件的唯一識別碼。
typestring事件類型,固定為 response.content_part.done。
response_idstring回應的唯一識別碼。
item_idstring訊息項的唯一識別碼。
output_indexinteger固定為 0。
content_indexinteger固定為 0。
partobject內容部分資訊。
屬性
typestring內容部分的類型。
textstring內容部分的文字。
{
"event_id": "event_VN4Q4GJugLcc1S23viW8E",
"type": "response.content_part.done",
"response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
"item_id": "item_JvJauNH2CTXb1D9WV6pD4",
"output_index": 0,
"content_index": 0,
"part": {
"type": "audio",
"text": "Hello, I am a large language model developed by Alibaba Cloud. My name is Qwen. How can I help you?"
}
}