本文介绍 Qwen-Omni-Realtime API 的服务端事件,包括工具调用(Function Calling)相关事件。
error
服务端返回的错误信息。
event_idstringtypestringerror。errorobject属性
属性
typestringcodestringmessagestringparamstringsession.modalities。session.created
客户端连接后,服务端返回的第一个事件,包含本次连接的默认配置信息。
event_idstringtypestringsession.created。sessionobject属性
属性
objectstringrealtime.session。modelstringmodalitiesarrayvoicestringinput_audio_formatstringpcm。输入音频要求为16 kHz采样率的PCM音频流。output_audio_formatstringpcm。输出音频为24 kHz采样率的PCM音频流。当前不支持自定义输出采样率。input_audio_transcriptionobject属性
属性
modelstringqwen3-asr-flash-realtime,不支持修改。turn_detectionobject属性
属性
typestringserver_vad(默认值)、semantic_vad 或 semantic_vad_ec。其中,semantic_vad_ec 适用于 Qwen3.8-Omni-Flash-Realtime 系列模型。详情请参见客户端事件。thresholdfloatsilence_duration_msintegeridle_timeout_msintegerserver_vad 模式下,使用 qwen3.5-omni-plus-realtime 或 qwen3.5-omni-flash-realtime 模型时返回。enable_searchbooleansearch_optionsobjecttemperaturefloatqwen3.8-omni-flash-realtime 返回的默认会话示例。session.updated
收到用户的 session.update 请求后,若处理成功,则返回此事件;若出错,则返回 error 事件。
event_idstringtypestringsession.updated。sessionobject属性
属性
temperaturefloatmodalitiesarrayvoicestringinstructionsstringaudioobjectsession.audio.input.format / session.audio.output.format,服务端将在 session.updated 中按相同嵌套结构回显。未使用嵌套字段的客户端,服务端事件结构保持原有行为。属性
属性
inputobject属性
属性
formatobject属性
属性
typestringpcm(默认值)、wav。sample_rateintegeroutputobject属性
属性
formatobject属性
属性
typestringpcm(默认值)、wav。sample_rateintegerinput_audio_formatstringoutput_audio_formatstringinput_audio_transcriptionobject属性
属性
modelstringqwen3-asr-flash-realtime,不支持修改。turn_detectionobject属性
属性
typestringserver_vad(默认值)、semantic_vad 或 semantic_vad_ec。其中,semantic_vad_ec 适用于 Qwen3.8-Omni-Flash-Realtime 系列模型。详情请参见客户端事件。thresholdfloatsilence_duration_msintegeridle_timeout_msintegerserver_vad 模式下,使用 qwen3.5-omni-plus-realtime 或 qwen3.5-omni-flash-realtime 模型时返回。enable_searchboolean(可选)search_optionsobject(可选)toolsarray(可选)type="function" 的 Function Calling 工具。Qwen3.8-Omni-Flash-Realtime 的 MCP 配置字段见客户端工具配置;MCP 连接地址和凭证不会在 session.updated 中回显。属性
属性
typestring(必选)function。functionobject属性
属性
namestring(必选)get_current_weather或get_current_time。descriptionstring(可选)parametersobject(可选)属性
属性
typestring(必选)object。propertiesobject(可选)type)与描述(description)的对象。requiredarray(可选)top_pfloattop_kintegermax_tokensintegerrepetition_penaltyfloatpresence_penaltyfloatseedintegerinput_audio_buffer.speech_started
在 VAD 模式下,当服务端在音频缓冲区中检测到语音开始时,会返回此事件。
若服务端尚未检测到语音,则每次向缓冲区添加音频时都可能触发此事件。
event_idstringtypestringinput_audio_buffer.speech_started。audio_start_msintegeritem_idstring用户消息项用于将用户输入追加到对话历史,供模型后续推理与生成使用。
input_audio_buffer.speech_stopped
在 VAD 模式下,当音频缓冲区中检测到语音结束时,服务端会返回此事件。
同时,服务端还会返回一个 conversation.item.created 事件,以创建对应的用户消息项。
event_idstringtypestringinput_audio_buffer.speech_stopped。audio_end_msintegeritem_idstringinput_audio_buffer.committed
当输入音频缓冲区被提交时返回此事件。
- 在VAD模式下,当检测到用户说话结束时,服务端会自动提交音频缓冲区并返回此事件。
- 在 Manual 模式下,当客户端发送
input_audio_buffer.commit事件后,服务端返回此事件。
event_idstringtypestringinput_audio_buffer.committed。item_idstringinput_audio_buffer.cleared
客户端发送input_audio_buffer.clear事件后,服务端将返回此事件。
event_idstringtypestringinput_audio_buffer.cleared。conversation.item.created
当对话项创建时返回此事件。
event_idstringtypestringconversation.item.created。response_idstring(条件必填)item.type 为 mcp_approval_request 时返回;生成本次 MCP 调用的父 Response ID。item_idstring(条件必填)item.type 为 mcp_approval_request 时返回;审批请求 item ID,与 item.id 相同。previous_item_idstring(条件必填)item.type 为 mcp_approval_request 时返回;被审批的 mcp_call item ID。itemobject属性
属性
idstringobjectstringmessage 和 function_call 项固定为 realtime.item;MCP 项若返回该字段,值也为 realtime.item。statusstringmcp_call 初始项必填,值为 in_progress。rolestringcontentarray[object]message 时存在。下列字段对应本页示例中的数组元素。数组元素
数组元素
typestringinput_audio。typestringmessage(常规消息)和 function_call(工具调用)。Qwen3.8-Omni-Flash-Realtime 还可返回 mcp_list_tools、mcp_call、mcp_approval_request,事件示例见MCP 对话项。namestringfunction_call 时,被调用的函数名称。call_idstringfunction_call 时,本次函数调用的唯一 ID。argumentsstringfunction_call 时,函数调用的参数(JSON 字符串)。type=mcp_list_tools
type=mcp_list_tools
item.id 与工具发现状态事件的 item_id 相同。server_labelstring(必填)toolsarray[object](必填)allowed_tools 过滤的工具定义,发现失败时为空数组。数组元素
数组元素
namestring(必填)descriptionstring(可选)input_schemaobject(必填)属性
属性
typestring(必填)object。propertiesobject(可选)city 是参数名,其 type 和 description 分别说明数据类型和用途;各参数的 JSON Schema 由 MCP Server 定义。requiredarray[string](可选)additionalProperties、$defs、oneOf、anyOf、allOf 等其他标准 JSON Schema 字段按原始 schema 保留并传递。annotationsobject(可选)属性
属性
titlestring(可选)readOnlyHintboolean(可选)destructiveHintboolean(可选)idempotentHintboolean(可选)openWorldHintboolean(可选)errorobject(可选)属性
属性
typestring(必填)tool_execution_error。messagestring(必填)type=mcp_call(初始项)
type=mcp_call(初始项)
objectstring(必填)realtime.item。statusstring(必填)in_progress。server_labelstring(必填)namestring(必填)call_idstring(必填)argumentsstring(必填)type=mcp_approval_request
type=mcp_approval_request
item.id 应在审批回复中原样填入 approval_request_id。server_labelstring(必填)namestring(必填)argumentsstring(必填)call_idstring(必填)conversation.item.input_audio_transcription.delta
开启输入音频转录后,此事件会在用户说话过程中高频发送,用于展示实时识别的中间结果。您可以通过拼接 text + stash 获取当前最完整的句子预览。
event_idstringtypestringconversation.item.input_audio_transcription.delta。item_idstringcontent_indexintegertextstringstashstringlanguagestringemotionstringneutral(平静)、happy(愉快)、sad(悲伤)、angry(愤怒)、surprised(惊讶)、disgusted(厌恶)、fearful(恐惧)。text + stash。点击查看示例
点击查看示例
时间点 | 用户说话进度 | API 响应 (text 和 stash) | 客户端 UI 应显示 (text + stash) |
|---|---|---|---|
T1 | "今天……" | text: "" stash: "今天" | 今天 |
T2 | "……天气……" | text: "" stash: "今天天气" | 今天天气 |
T3 | "……不错" | text: "今天" stash: "天气不错" | 今天天气不错 (注意,"今天"已被确认并移入text) |
T4 | (短暂停顿) | text: "今天天气不错," stash: "" | 今天天气不错, (前半句完全确认) |
T5 | "……阳光……" | text: "今天天气不错," stash: "阳光" | 今天天气不错,阳光 |
T6 | "……明媚。" | text: "今天天气不错," stash: "阳光明媚。" | 今天天气不错,阳光明媚。 |
T7 | (结束说话) | - | 使用 conversation.item.input_audio_transcription.completed 的 transcript 内容作为最终结果。 |
conversation.item.input_audio_transcription.completed
此事件表示用户音频写入缓冲区后生成的转录结果。其转录由内置的语音识别模型(固定为 qwen3-asr-flash-realtime)处理,不支持修改。
语音识别模型生成的转录文本可能与 Qwen-Omni-Realtime 模型的理解存在差异,仅供参考。
event_idstringtypestringconversation.item.input_audio_transcription.completed。item_idstringcontent_indexintegertranscriptstringconversation.item.input_audio_transcription.failed
启用输入音频转录后,若用户音频转录失败,服务端会返回此事件。此事件独立于 error 事件,便于客户端识别。
event_idstringtypestringconversation.item.input_audio_transcription.failed。item_idstringcontent_indexintegererrorobject属性
属性
codestringmessagestringparamstringresponse.created
当服务端生成新的模型响应时,会返回此事件。
event_idstringtypestringresponse.created。responseobject属性
属性
idstringconversation_idstringobjectstringrealtime.response。statusstring[completed, failed, in_progress, or incomplete]范围内。modalitiesarrayvoicestringoutputarrayresponse.done
响应生成完成后,服务端会返回此事件。事件中的 response 对象包含除原始音频数据外的全部输出项。
event_idstringtypestringresponse.done。responseobject属性
属性
idstringconversation_idstringobjectstringrealtime.response。statusstringmodalitiesarrayvoicestringoutputarray数组元素
数组元素
idstringtypestringmessage(常规消息)、function_call(工具调用),Qwen3.8-Omni-Flash-Realtime 还支持 mcp_call,事件示例见MCP 对话项。objectstringmessage 和 function_call 项固定为 realtime.item;MCP 项若返回该字段,值也为 realtime.item。statusstringrolestringcontentarraymessage 时存在;每个元素是输出内容对象。数组元素
数组元素
typestringtext;输出包含音频时,为audio。textstringtranscriptstringnamestringfunction_call 时,被调用的函数名称。call_idstringfunction_call 时,函数调用的唯一 ID。argumentsstringfunction_call 时,函数调用的完整参数(JSON 字符串)。type=mcp_call(最终项)
type=mcp_call(最终项)
statusstring(必填)completed 或 failed。server_labelstring(必填)namestring(必填)call_idstring(必填)argumentsstring(必填)outputstring(可选)tools/call.result 对象序列化后的 JSON 字符串;部分失败场景也可能出现。errorobject(可选)属性
属性
typestring(必填)tool_execution_error。messagestring(必填)isError=true 时最终状态为 failed,也可能保留原始 output。usageobject属性
属性
total_tokensintegerinput_tokensintegeroutput_tokensintegerinput_tokens_detailsobjecttext_tokens(文本 Token 数)和 audio_tokens(音频 Token 数)。output_tokens_detailsobjecttext_tokens(文本 Token 数)和 audio_tokens(音频 Token 数)。pluginsobject(可选)enable_search)时返回。属性
属性
searchobject属性
属性
countintegerstrategystringresponse.text.delta
当输出模态仅包含文本,且模型增量生成新的文本时,服务端将返回此事件。
event_idstringtypestringresponse.text.delta。deltastringresponse_idstringitem_idstringoutput_indexintegercontent_indexintegerresponse.text.done
当输出模态仅包含文本,且模型生成的文本结束时,服务端将返回此事件。
当响应中断、不完整或取消时,也会返回此事件。
event_idstringtypestringresponse.text.done。response_idstringitem_idstringoutput_indexintegercontent_indexintegertextstringresponse.audio.delta
WebSocket 接入时,当输出模态包含音频,且模型增量生成新的音频数据时,服务端返回此事件。WebRTC 接入时,音频通过 RTP 音频轨道传输,不返回此事件。
event_idstringtypestringresponse.audio.delta。response_idstringitem_idstringoutput_indexintegercontent_indexintegerdeltastringresponse.audio.done
当输出模态包含音频,且模型完成生成音频数据时,服务端将返回此事件。
当响应中断、不完整或取消时,也会返回此事件。
event_idstringtypestringresponse.audio.done。response_idstringitem_idstringoutput_indexintegercontent_indexintegerresponse.audio_transcript.delta
当输出模态包含音频,且模型增量生成新的音频对应的文本时,服务端将返回 response.audio_transcript.delta 事件。
event_idstringtypestringresponse.audio_transcript.delta。response_idstringitem_idstringoutput_indexintegercontent_indexintegerdeltastringresponse.audio_transcript.done
当输出模态包含音频,且模型完成音频转录后,服务端将返回 response.audio_transcript.done 事件。
event_idstringtypestringresponse.audio_transcript.done。response_idstringitem_idstringoutput_indexintegercontent_indexintegertranscriptstringresponse.function_call_arguments.delta
当模型以流式方式生成函数调用的参数字符串时,每产生一段新内容,服务端推送一次本事件。客户端应按接收顺序将各事件中的 delta 字段拼接,得到与当前进度一致的参数文本;完整内容以随后的 response.function_call_arguments.done 为准。
event_idstringtypestringresponse.function_call_arguments.delta。response_idstringitem_idstringoutput_indexintegercall_idstringdone 事件保持一致。deltastringresponse.function_call_arguments.done
函数调用参数已全部生成完毕。本事件中的 arguments 为完整的参数字符串。客户端可在收到本事件后解析参数并调用本地工具函数;应以本事件中的完整 arguments 为准,而非 delta 拼接结果。
event_idstringtypestringresponse.function_call_arguments.done。response_idstringitem_idstringoutput_indexintegercall_idstringnamestringargumentsstringresponse.output_item.added
在响应生成过程中创建新项目时,服务端返回此事件。项目类型可以是 message(常规消息)、function_call(工具调用),Qwen3.8-Omni-Flash-Realtime 还支持 mcp_call,事件示例见MCP 对话项。
event_idstringtypestringresponse.output_item.added。response_idstringoutput_indexintegeritemobject属性
属性
idstringobjectstringmessage 和 function_call 项固定为 realtime.item;MCP 项若返回该字段,值也为 realtime.item。statusstringrolestringcontentarraymessage 时存在。本页示例中初始为空数组;完成项的内容见 response.output_item.done 示例。typestringmessage(常规消息)、function_call(工具调用),Qwen3.8-Omni-Flash-Realtime 还支持 mcp_call,事件示例见MCP 对话项。namestringfunction_call 时,被调用的函数名称。call_idstringfunction_call 时,本次函数调用的唯一 ID。argumentsstringfunction_call 时,函数调用的参数(JSON 字符串)。在 added 事件中初始为空字符串。type=mcp_call(初始项)
type=mcp_call(初始项)
objectstring(必填)realtime.item。statusstring(必填)in_progress。server_labelstring(必填)namestring(必填)call_idstring(必填)argumentsstring(必填)response.mcp_call_arguments.done 和最终项为准。response.output_item.done
当新的项目输出完成时,服务端返回此事件。
event_idstringtypestringresponse.output_item.done。response_idstringoutput_indexintegeritemobject属性
属性
idstringobjectstringmessage 和 function_call 项固定为 realtime.item;MCP 项若返回该字段,值也为 realtime.item。statusstringrolestringcontentarray[object]message 时存在。下列字段对应本页示例中的数组元素。数组元素
数组元素
typestringaudio。textstringtypestringmessage(常规消息)、function_call(工具调用),Qwen3.8-Omni-Flash-Realtime 还支持 mcp_call,事件示例见MCP 对话项。namestringfunction_call 时,被调用的函数名称。call_idstringfunction_call 时,本次函数调用的唯一 ID。argumentsstringfunction_call 时,函数调用的完整参数(JSON 字符串)。type=mcp_call(最终项)
type=mcp_call(最终项)
statusstring(必填)completed 或 failed。server_labelstring(必填)namestring(必填)call_idstring(必填)argumentsstring(必填)outputstring(可选)tools/call.result 对象序列化后的 JSON 字符串;部分失败场景也可能出现。errorobject(可选)属性
属性
typestring(必填)tool_execution_error。messagestring(必填)isError=true 时最终状态为 failed,也可能保留原始 output。response.content_part.added
在响应生成过程中,向助手消息项中添加新内容部分时,服务端返回此事件。
event_idstringtypestringresponse.content_part.added。response_idstringitem_idstringoutput_indexintegercontent_indexintegerpartobject属性
属性
typestringtextstringresponse.content_part.done
在助手消息项中的内容部分完成流式传输时,服务端返回此事件。
event_idstringtypestringresponse.content_part.done。response_idstringitem_idstringoutput_indexintegercontent_indexintegerpartobject属性
属性
typestringtextstringMCP 事件
本节介绍 qwen3.8-omni-flash-realtime 的 WebSocket 事件与字段。基础事件与字段见前述事件说明。表中“必填”表示所属对象出现时必须提供。ID 均为不透明字符串,不应依赖其长度、前缀或生成规则。arguments、output 的外层类型为 string,读取内容时需要再次解析 JSON。MCP 连接、工具发现和调用受服务配额及超时限制。
mcp_list_tools.*
以下三个事件具有相同的字段结构:
| 事件 type | 触发时机 |
|---|---|
| mcp_list_tools.in_progress | 开始发现某个 MCP Server 的工具 |
| mcp_list_tools.completed | 工具发现成功并完成 allowed_tools 过滤 |
| mcp_list_tools.failed | 工具发现失败、超时或结果超过服务限制 |
event_idstring(必选)typestring(必选)item_idstring(必选)mcp_list_tools.in_progress 可能早于 session.updated 到达。对于 completed 和 failed,服务端会先发送包含最终工具列表或错误的 conversation.item.created,再发送相同 item_id 的状态事件。示例:response.mcp_call_arguments.delta
event_idstring(必选)typestring(必选)response_idstring(必选)item_idstring(必选)output_indexinteger(必选)deltastring(必选)obfuscationstring(可选)response.mcp_call_arguments.done
event_idstring(必选)typestring(必选)response_idstring(必选)item_idstring(必选)output_indexinteger(必选)argumentsstring(必选)response.mcp_call.*
| 事件 type | 触发时机 |
|---|---|
| response.mcp_call.in_progress | 参数生成完成,且审批通过或无需审批,开始调用 MCP Server |
| response.mcp_call.completed | MCP 工具调用成功 |
| response.mcp_call.failed | 连接、协议、工具业务错误、审批拒绝、审批超时、调用超时或取消 |
event_idstring(必选)typestring(必选)item_idstring(必选)output_indexinteger(必选)MCP 对话项
以下对象是事件中 item 的取值类型,适用于 Qwen3.8-Omni-Flash-Realtime。
mcp_list_tools
该对象通过 conversation.item.created.item 返回;字段见 conversation.item.created 的 type=mcp_list_tools 分支。
示例:
初始 mcp_call
模型选择 MCP 工具时,该对象出现在 response.output_item.added.item 中,也可能通过 conversation.item.created.item 返回;字段见 response.output_item.added 和 conversation.item.created 的对应 item 分支。
response.output_item.added 示例:
mcp_approval_request
该对象通过 conversation.item.created 返回;事件顶层字段和审批请求 item 字段见 conversation.item.created。
示例:
最终 mcp_call
MCP 调用进入终态后,该对象出现在 response.output_item.done.item 中,并进入父 response.done.response.output 的最终快照;字段见 response.output_item.done 和 response.done 的对应分支。
- 成功
- 失败
MCP 错误
MCP 错误可能发生在工具发现或工具调用阶段。工具发现失败时的 error 字段见 conversation.item.created 的 mcp_list_tools 分支;工具调用失败时见 response.output_item.done 的 mcp_call 分支。
相关文档:实时(Qwen-Omni-Realtime)。