WebSocket 服务端事件参考
qwen3.5-livetranslate-flash-realtime API 的服务端事件。
服务端返回的错误。
连接建立时发送,包含默认会话配置。
所有翻译完成后发送。
仅在您发送 session.finish 后触发。收到此事件后可以断开连接。
服务端检测到音频流中出现语音活动时发送。
服务端检测到语音片段结束时发送。
Manual 模式(
客户端发送
当对话中创建新的消息项时,服务端返回此事件。以下场景会触发此事件:
服务端开始生成新响应时发送。
响应生成完成时发送。
纯文本模式下,模型增量生成文本时发送。
纯文本输出完成时发送。
模型增量生成音频数据时发送。
音频生成完成时发送。
流式返回源语言的语音识别结果。需要设置
语音识别完成时发送,包含最终识别结果。需要设置
当输入了音频但识别失败时,服务端发送该事件。与其他
输出包含音频时,实时流式返回翻译文本。
音频输出的翻译文本生成完成时发送。
响应生成过程中创建新输出项时发送。
输出项完成时发送。
新的内容部分开始时发送。
内容部分完成时发送。
参考:语音翻译。
error
服务端返回的错误。
Example
string
body
事件 ID。
string
body
固定为
error。object
body
错误详情。
session.created
连接建立时发送,包含默认会话配置。
Example
string
body
事件 ID。
string
body
固定为
session.created。object
body
会话配置。
session.updated
session.update 请求成功后发送。如果出错,服务端会返回 error 事件。
Example
string
body
事件 ID。
string
body
固定为
session.updated。object
body
会话配置。
session.finished
所有翻译完成后发送。
仅在您发送 session.finish 后触发。收到此事件后可以断开连接。
Example
string
body
事件 ID。
string
body
固定为
session.finished。input_audio_buffer.speech_started
服务端检测到音频流中出现语音活动时发送。
Example
string
body
事件 ID。
string
body
固定为
input_audio_buffer.speech_started。integer
body
检测到语音起始位置的时间偏移(毫秒)。
input_audio_buffer.speech_stopped
服务端检测到语音片段结束时发送。
Example
string
body
事件 ID。
string
body
固定为
input_audio_buffer.speech_stopped。integer
body
检测到语音结束位置的时间偏移(毫秒)。
input_audio_buffer.committed
Manual 模式(turn_detection 为 null)下,客户端发送 input_audio_buffer.commit 事件后,服务端返回此事件进行确认,并自动开始生成翻译响应。
Example
string
body
本次事件唯一标识符。
string
body
固定为
input_audio_buffer.committed。input_audio_buffer.cleared
客户端发送 input_audio_buffer.clear 事件后,服务端返回此事件进行确认,表示已清空缓冲区中尚未提交的音频数据。
Example
string
body
本次事件唯一标识符。
string
body
固定为
input_audio_buffer.cleared。conversation.item.created
当对话中创建新的消息项时,服务端返回此事件。以下场景会触发此事件:
- 服务端开始生成翻译响应时,创建对应的 assistant 消息项(此时
content为空数组,内容随流式响应逐步填充)。 - Manual 模式下,客户端发送
input_audio_buffer.commit事件后,服务端会额外创建一个对应用户输入音频的消息项(content中包含{"type": "input_audio"})。
item.id 与翻译结果事件的 previous_item_id 相同。客户端可据此关联原文和译文,并同时展示。
Example
string
body
本次事件唯一标识符。
string
body
固定为
conversation.item.created。string
body
前一消息项的唯一标识符。对于翻译结果事件,该值与同一 VAD 片段的语音识别结果消息项
item.id 相同。object
body
消息项信息。
response.created
服务端开始生成新响应时发送。
Example
string
body
事件 ID。
string
body
固定为
response.created。object
body
响应对象。
response.done
响应生成完成时发送。response 对象包含所有输出项,但不包含原始音频数据。
Example
string
body
事件 ID。
string
body
固定为
response.done。object
body
响应对象。
response.text.text
纯文本模式下,模型增量生成文本时发送。
Example
string
body
事件 ID。
string
body
固定为
response.text.text。string
body
增量文本片段。
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
response.text.done
纯文本输出完成时发送。
响应被中断、未完成或取消时也会发送此事件。
Example
string
body
事件 ID。
string
body
固定为
response.text.done。string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
string
body
完整文本输出。
response.audio.delta
模型增量生成音频数据时发送。
Example
string
body
事件 ID。
string
body
固定为
response.audio.delta。string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
string
body
Base64 编码的音频数据片段。
response.audio.done
音频生成完成时发送。
响应被中断、未完成或取消时也会发送此事件。此事件不包含完整音频数据。
Example
string
body
事件 ID。
string
body
固定为
response.audio.done。string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
conversation.item.input_audio_transcription.text
流式返回源语言的语音识别结果。需要设置 input_audio_transcription.model。
Example
string
body
事件 ID。
string
body
固定为
conversation.item.input_audio_transcription.text。string
body
消息项 ID。
integer
body
固定为 0。
string
body
已确认的识别文本。
string
body
待确认的识别文本,可能被后续事件修正。
string
body
检测到的源语言。
string
body
被识别音频的情感。支持的情感如下:
surprised:惊讶neutral:平静happy:愉快sad:悲伤disgusted:厌恶angry:愤怒fearful:恐惧
conversation.item.input_audio_transcription.completed
语音识别完成时发送,包含最终识别结果。需要设置 input_audio_transcription.model。
Example
string
body
事件 ID。
string
body
固定为
conversation.item.input_audio_transcription.completed。string
body
消息项 ID。
integer
body
固定为 0。
string
body
源语言的最终识别结果。
string
body
检测到的源语言。
string
body
被识别音频的情感。支持的情感如下:
surprised:惊讶neutral:平静happy:愉快sad:悲伤disgusted:厌恶angry:愤怒fearful:恐惧
conversation.item.input_audio_transcription.failed
当输入了音频但识别失败时,服务端发送该事件。与其他 error 事件分开处理,便于客户端识别相关的具体项目。
Example
string
body
本次事件唯一标识符。
string
body
固定为
conversation.item.input_audio_transcription.failed。string
body
关联的对话项 ID。
integer
body
包含音频的内容部分的索引。
string
body
错误代码。
string
body
错误消息。
response.audio_transcript.text
输出包含音频时,实时流式返回翻译文本。
Example
string
body
事件 ID。
string
body
固定为
response.audio_transcript.text。string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
string
body
已确认的翻译片段。
string
body
追加在
text 之后的临时文本,构成部分翻译结果。服务端通过 response.audio_transcript.text 事件持续更新 text 和 stash,直到 response.audio_transcript.done 事件返回最终翻译结果(transcript 字段)。response.audio_transcript.done
音频输出的翻译文本生成完成时发送。
Example
string
body
事件 ID。
string
body
固定为
response.audio_transcript.done。string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
string
body
最终翻译文本。
response.output_item.added
响应生成过程中创建新输出项时发送。
Example
string
body
事件 ID。
string
body
固定为
response.output_item.added。string
body
响应 ID。
integer
body
固定为 0。
object
body
输出项。
response.output_item.done
输出项完成时发送。
Example
string
body
事件 ID。
string
body
固定为
response.output_item.done。string
body
响应 ID。
integer
body
固定为 0。
object
body
输出项。
response.content_part.added
新的内容部分开始时发送。
Example
string
body
事件 ID。
string
body
固定为
response.content_part.added。string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
object
body
内容部分。
response.content_part.done
内容部分完成时发送。
Example
string
body
事件 ID。
string
body
固定为
response.content_part.done。string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
object
body
内容部分。