本文介紹 Qwen-Omni-Realtime API 的服務端事件,包括工具調用(Function Calling)相關事件。
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 會話的配置資訊。 屬性 objectstring 固定為realtime.session。 modelstring 使用的模型。 modalitiesarray 模型輸出模態設定。 voicestring 模型產生音訊音色。 input_audio_formatstring 使用者輸入音訊格式,當前僅支援設為pcm。輸入音頻要求為16 kHz採樣率的PCM音頻流。 output_audio_formatstring 模型輸出音訊格式,當前僅支援設為pcm。輸出音頻為24 kHz採樣率的PCM音頻流。當前不支援自訂輸出採樣率。 input_audio_transcriptionobject 語音轉錄的配置。 屬性 modelstring 語音轉錄模型,固定為qwen3-asr-flash-realtime,不支援修改。 turn_detectionobject 語音活動檢測(VAD)的配置。 屬性 typestring VAD類型。取值:server_vad(預設值)或 semantic_vad。詳情請參見用戶端事件。 thresholdfloat VAD檢測閾值。 silence_duration_msinteger 檢測語音停止的靜音期間。 idle_timeout_msinteger 靜默逾時時間(毫秒)。僅在 server_vad 模式下,使用 qwen3.5-omni-plus-realtime 或 qwen3.5-omni-flash-realtime 模型時返回。 enable_searchboolean 是否啟用連網搜尋功能。僅 Qwen3.5-Omni-Realtime 系列模型支援。 search_optionsobject 連網搜尋選項配置。 temperaturefloat 模型的溫度參數。 | 以下為北京地域 qwen3.8-omni-flash-realtime 傳回的預設會話範例。 {
"event_id": "event_QQubXbhHMyXmKaSuE6PQ8",
"type": "session.created",
"session": {
"input_audio_format": "pcm",
"input_audio_transcription": {
"model": "qwen3-asr-flash-realtime"
},
"id": "sess_MjEctgJ4ziXPEioCzSSvK",
"object": "realtime.session",
"modalities": [
"text",
"audio"
],
"turn_detection": {
"type": "server_vad",
"silence_duration_ms": 800,
"interrupt_response": true,
"create_response": true,
"threshold": 0.5,
"prefix_padding_ms": 300
},
"model": "qwen3.8-omni-flash-realtime",
"voice": "Tina",
"output_audio_format": "pcm"
}
}
|
session.updated
收到使用者的 session.update 請求後,若處理成功,則返回此事件;若出錯,則返回 error 事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為session.updated。 sessionobject 會話的配置資訊。 屬性 temperaturefloat 模型的溫度參數。 modalitiesarray 模型輸出模態設定。 voicestring 模型產生音訊音色。 instructionsstring 模型的目標與角色。 audioobject 回顯的音頻格式配置。若用戶端傳入了 session.audio.input.format / session.audio.output.format,服務端將在 session.updated 中按相同嵌套結構回顯。未使用嵌套欄位的用戶端,服務端事件結構保持原有行為。 屬性 audio.input.format.typestring 使用者輸入音頻格式。可選值:pcm(預設值)、wav。 audio.input.format.sample_rateinteger 使用者輸入音頻採樣率,單位為 Hz。 audio.output.format.typestring 模型輸出音頻格式。可選值:pcm(預設值)、wav。 audio.output.format.sample_rateinteger 模型輸出音頻採樣率,單位為 Hz。 input_audio_formatstring 歷史相容欄位,回顯用戶端配置的輸入音頻格式。 output_audio_formatstring 歷史相容欄位,回顯用戶端配置的輸出音頻格式。 input_audio_transcriptionobject 語音轉錄的配置。 屬性 modelstring 語音轉錄模型,固定為qwen3-asr-flash-realtime,不支援修改。 turn_detectionobject 語音活動檢測(VAD)的配置。 屬性 typestring VAD類型。取值:server_vad(預設值)或 semantic_vad。詳情請參見用戶端事件。 thresholdfloat VAD檢測閾值。 silence_duration_msinteger 檢測語音停止的靜音期間。 idle_timeout_msinteger 靜默逾時時間(毫秒)。僅在 server_vad 模式下,使用 qwen3.5-omni-plus-realtime 或 qwen3.5-omni-flash-realtime 模型時返回。 enable_searchboolean(可選) 是否啟用連網搜尋功能。僅 Qwen3.5-Omni-Realtime 系列模型支援。 search_optionsobject(可選) 連網搜尋選項配置。 toolsarray(可選) 工具定義列表。配置後模型可根據使用者輸入自主決定是否調用工具。 屬性 typestring(必選) 固定為 function。 function.namestring(必選) 自訂的工具函數名稱,建議使用與函數相同的名稱,如get_current_weather或get_current_time。 function.descriptionstring(可選) 對工具函數功能的描述,大模型會參考該欄位來選擇是否使用該工具函數。 function.parametersobject(可選) 對工具函數入參的描述,大模型會參考該欄位來進行入參的提取。如果工具函數不需要輸入參數,則無需指定。 屬性 typestring(必選) 固定為 object。 propertiesobject(可選) 描述各入參的名稱、資料類型與描述。Key 值為入參的名稱,Value 值為包含資料類型(type)與描述(description)的對象。 requiredarray(可選) 指定哪些入參為必填項。 top_pfloat 核採樣的機率閾值。 top_kinteger 模型產生過程中,採樣候選集的大小。 max_tokensinteger 模型在本次請求返回的最大 Token 數。 repetition_penaltyfloat 控制模型產生時,連續序列中的重複度*。* presence_penaltyfloat 控制模型在產生內容時的重複度。 seedinteger 模型在每次請求時,運行結果一致性程度。 | {
"event_id": "event_X1HsXS4b4uptp6yo1LgKd",
"type": "session.updated",
"session": {
"id": "sess_Aih6vAcY5Ddt6jwFx1tCa",
"object": "realtime.session",
"model": "qwen3.5-omni-flash-realtime",
"modalities": [
"text",
"audio"
],
"audio": {
"input": {
"format": {
"type": "pcm",
"sample_rate": 16000
}
},
"output": {
"format": {
"type": "wav",
"sample_rate": 24000
}
}
},
"instructions": "你是個人助理小雲,請你準確且友好地解答使用者的問題,始終以樂於助人的態度回應。",
"voice": "Tina",
"input_audio_format": "pcm",
"output_audio_format": "pcm",
"input_audio_transcription": {
"model": "qwen3-asr-flash-realtime"
},
"turn_detection": {
// 取值為server_vad或semantic_vad(僅qwen3.5-omni-realtime支援)
"type": "server_vad",
"threshold": 0.1,
"prefix_padding_ms": 500,
"silence_duration_ms": 900,
"create_response": true,
"interrupt_response": true
},
"enable_search": true,
"search_options": {
"enable_source": true
},
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "當你想查詢指定城市的天氣時非常有用。",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "城市名稱"}
},
"required": ["location"]
}
}
}
],
"temperature": 0.8,
"max_response_output_token": "inf",
"max_tokens": 16384,
"repetition_penalty": 1.05,
"presence_penalty": 0.0,
"top_k": 50,
"top_p": 1.0,
"seed":-1
}
}
|
在 VAD 模式下,當服務端在音頻緩衝區中檢測到語音開始時,會返回此事件。
若服務端尚未檢測到語音,則每次向緩衝區添加音頻時都可能觸發此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為input_audio_buffer.speech_started。 audio_start_msinteger 從音頻開始寫入緩衝區到首次檢測到語音所經過的毫秒數。 item_idstring 語音停止時將建立的使用者訊息項的 ID。
使用者訊息項用於將使用者輸入追加到對話歷史,供模型後續推理與產生使用。
| {
"event_id": "event_Pvp8nEhsQuGCQbFJ9x58n",
"type": "input_audio_buffer.speech_started",
"audio_start_ms": 3647,
"item_id": "item_YbAiGvK2H7YaS34o4R6Ba"
}
|
在 VAD 模式下,當音頻緩衝區中檢測到語音結束時,服務端會返回此事件。
同時,服務端還會返回一個 conversation.item.created 事件,以建立對應的使用者訊息項。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為input_audio_buffer.speech_stopped。 audio_end_msinteger 語音停止時刻距會話開始經過的毫秒數。 item_idstring 將建立的使用者訊息項的 ID。 | {
"event_id": "event_UhQiqNVRsgUiq4KUS5Xb5",
"type": "input_audio_buffer.speech_stopped",
"audio_end_ms": 4453,
"item_id": "item_YbAiGvK2H7YaS34o4R6Ba"
}
|
當輸入音頻緩衝區被提交時返回此事件。
- 在VAD模式下,當檢測到使用者說話結束時,服務端會自動認可音頻緩衝區並返回此事件。
- 在 Manual 模式下,當用戶端發送
input_audio_buffer.commit事件後,服務端返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為input_audio_buffer.committed。 item_idstring 將建立的使用者訊息項的 ID。 | {
"event_id": "event_Iy6sUzL1nmdFgshFYxJEz",
"type": "input_audio_buffer.committed",
"item_id": "item_YbAiGvK2H7YaS34o4R6Ba"
}
|
用戶端發送input_audio_buffer.clear事件後,服務端將返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為input_audio_buffer.cleared。 | {
"event_id": "event_RoUu4T8yExPMI37GKwaOC",
"type": "input_audio_buffer.cleared"
}
|
conversation.item.created
當對話項建立時返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為conversation.item.created。 itemobject 要添加到對話中的項。 屬性 idstring 對話項的唯一ID。 objectstring 始終為 realtime.item 。 statusstring 對話項的狀態。 rolestring 訊息的角色。 contentstring 訊息的內容。當 type 為 message 時存在。 typestring 對話項的類型。可選值為 message(常規訊息)或 function_call(工具調用)。 namestring 當 type 為 function_call 時,被調用的函數名稱。 call_idstring 當 type 為 function_call 時,本次函數調用的唯一 ID。 argumentsstring 當 type 為 function_call 時,函數調用的參數(JSON 字串)。 | {
"event_id": "event_JEfkrr9gO3Ny7Xcv9bGVd",
"type": "conversation.item.created",
"item": {
"id": "item_YbAiGvK2H7YaS34o4R6Ba",
"object": "realtime.item",
"type": "message",
"status": "in_progress",
"role": "assistant",
"content": [
{
"type": "input_audio"
}
]
}
}
// 工具調用情境
{
"event_id": "event_S1hkaIQgcuQD8OEdOpGHQ",
"type": "conversation.item.created",
"item": {
"id": "item_FEG9qJGNkPcdf4et3p7BV",
"object": "realtime.item",
"type": "function_call",
"status": "in_progress",
"call_id": "call_bc0a7fb7235840f69ecfe4",
"name": "get_current_weather",
"arguments": ""
}
}
|
開啟輸入音頻轉錄後,此事件會在使用者說話過程中高頻發送,用於展示即時識別的中間結果。您可以通過拼接 text + stash 擷取當前最完整的句子預覽。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為conversation.item.input_audio_transcription.delta。 item_idstring 關聯的對話項 ID。 content_indexinteger 包含音訊內容部分的索引。 textstring 已確認的文本首碼。這是當前句子中,模型已確認不會再變更的部分。 stashstring 預識別的文本尾碼。這是緊跟在已確認部分之後,模型仍在處理、可能會被修正的臨時草稿。 languagestring 被識別音訊語種。 emotionstring 被識別音訊情感。可選值:neutral(平靜)、happy(愉快)、sad(悲傷)、angry(憤怒)、surprised(驚訝)、disgusted(厭惡)、fearful(恐懼)。 | {
"event_id": "event_C7jzoeSFuiwOZS6tR14yx",
"type": "conversation.item.input_audio_transcription.delta",
"item_id": "item_ThVYhLHOdeXb4bBSvzSFF",
"content_index": 0,
"text": "",
"stash": "今天天氣怎麼樣?",
"language": "zh",
"emotion": "neutral",
"obfuscation": "ABEXGYmxdmc97u"
}
在任何時刻,要擷取當前最完整的句子預覽,都需要將這兩個欄位拼接起來:即時預覽句子 = 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 內容作為最終結果。 |
|
此事件表示使用者音頻寫入緩衝區後產生的轉錄結果。其轉錄由內建的語音辨識模型(固定為 qwen3-asr-flash-realtime)處理,不支援修改。
語音辨識模型產生的轉錄文本可能與 Qwen-Omni-Realtime 模型的理解存在差異,僅供參考。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為conversation.item.input_audio_transcription.completed。 item_idstring 使用者訊息項的 ID。 content_indexinteger 當前固定為0。 transcriptstring 轉錄的常值內容。 | {
"event_id": "event_FrrZcxiDfTB9LD9p4pVng",
"type": "conversation.item.input_audio_transcription.completed",
"item_id": "item_YbAiGvK2H7YaS34o4R6Ba",
"content_index": 0,
"transcript": "喂,你好。"
}
|
啟用輸入音頻轉錄後,若使用者音頻轉錄失敗,服務端會返回此事件。此事件獨立於 error 事件,便於用戶端識別。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為conversation.item.input_audio_transcription.failed。 item_idstring 使用者訊息項的 ID。 content_indexinteger 當前固定為0。 errorobject 錯誤資訊。 屬性 code string 錯誤碼。 message string 錯誤訊息。 param string 錯誤相關的參數。 | {
"type": "conversation.item.input_audio_transcription.failed",
"item_id": "<item_id>",
"content_index": 0,
"error": {
"code": "<code>",
"message": "<message>",
"param": "<param>"
}
}
|
response.created
當服務端產生新的模型響應時,會返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.created。 responseobject 響應對象。 屬性 id string 響應的唯一 ID。 conversation_id string 當前會話的唯一ID。 object string 物件類型,此事件下固定為realtime.response。 status string 響應的狀態。在[completed, failed, in_progress, or incomplete]範圍內。 modalities array 響應的模態。 voice string 模型產生音訊音色。 output string 此事件下目前為空白。 | {
"event_id": "event_XuDavMzQN3KKepqGu3KRh",
"type": "response.created",
"response": {
"id": "resp_HaVOPdbmX6vifiV5pAfJY",
"object": "realtime.response",
"conversation_id": "conv_FjJaccpnvwHNo9cPVuzGc",
"status": "in_progress",
"modalities": [
"text",
"audio"
],
"voice": "Cherry",
"output_audio_format": "pcm",
"output": []
}
}
|
response.done
響應產生完成後,服務端會返回此事件。事件中的 response 對象包含除原始音頻資料外的全部輸出項。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.done。 responseobject 響應對象。 屬性 id string 響應的唯一 ID。 conversation_id string 當前會話的唯一ID。 object string 物件類型,此事件下固定為realtime.response。 status string 響應的狀態。 modalities array 響應的模態。 voice string 模型產生音訊音色。 output object 響應的輸出。 屬性 id string 響應輸出對應的ID。 type string 輸出項的類型,可選值為 message(常規訊息)或 function_call(工具調用)。 object string 輸出項的物件類型,當前固定為realtime.item。 status string 輸出項的狀態。 role string 輸出項的角色。 content array 輸出項的內容。當 type 為 message 時存在。 屬性 type string 輸出內容的類型。輸出為純文字時,為text;輸出包含音頻時,為audio。 text string 輸出的常值內容。 transcript string 音頻轉錄為文字後的內容。 name string 當 type 為 function_call 時,被調用的函數名稱。 call_id string 當 type 為 function_call 時,函數調用的唯一 ID。 arguments string 當 type 為 function_call 時,函數調用的完整參數(JSON 字串)。 usage object 本次響應的 Token 消耗資訊。 屬性 total_tokens integer 本次響應消耗的總 Token 數。 input_tokens integer 輸入 Token 數。 output_tokens integer 輸出 Token 數。 input_tokens_details object 輸入 Token 的分項詳情,包含 text_tokens(文本 Token 數)和 audio_tokens(音頻 Token 數)。 output_tokens_details object 輸出 Token 的分項詳情,包含 text_tokens(文本 Token 數)和 audio_tokens(音頻 Token 數)。 plugins object(可選) 外掛程式使用計量資訊。啟用連網搜尋(enable_search)時返回。 屬性 search object 連網搜尋計量資訊。 屬性 count integer 搜尋次數。 strategy string 搜尋策略。 | {
"event_id": "event_CSaxRRYLvbrfexDXAEuDG",
"type": "response.done",
"response": {
"id": "resp_HaVOPdbmX6vifiV5pAfJY",
"object": "realtime.response",
"conversation_id": "conv_FjJaccpnvwHNo9cPVuzGc",
"status": "completed",
"modalities": [
"text",
"audio"
],
"voice": "Cherry",
"output_audio_format": "pcm",
"output": [
{
"id": "item_Ls6MtCUWO7LM4E59QziNv",
"object": "realtime.item",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "audio",
"transcript": "你好呀!有什麼我可以幫你的嗎?"
}
]
}
],
"usage": {
"total_tokens": 377,
"input_tokens": 336,
"output_tokens": 41,
"input_tokens_details": {
"text_tokens": 228,
"audio_tokens": 108
},
"output_tokens_details": {
"text_tokens": 9,
"audio_tokens": 32
},
"plugins": {
"search": {
"count": 1,
"strategy": "agent"
}
}
}
}
}
// 工具調用情境
{
"event_id": "event_T1EFAJp43X2DWtDRmxTtx",
"type": "response.done",
"response": {
"id": "resp_TucN5QgymL5MA8vkJvFlS",
"object": "realtime.response",
"conversation_id": "conv_SEDZESRlefT8WvLSmEn6E",
"status": "completed",
"modalities": ["text", "audio"],
"voice": "Ethan",
"output_audio_format": "pcm",
"output": [
{
"id": "item_FEG9qJGNkPcdf4et3p7BV",
"object": "realtime.item",
"type": "function_call",
"status": "completed",
"call_id": "call_bc0a7fb7235840f69ecfe4",
"name": "get_current_weather",
"arguments": " {\"location\": \"杭州\"}"
}
],
"usage": {
"total_tokens": 567,
"input_tokens": 524,
"output_tokens": 43,
"input_tokens_details": {
"text_tokens": 487,
"audio_tokens": 37
},
"output_tokens_details": {
"text_tokens": 43
}
}
}
}
|
response.text.delta
當輸出模態僅包含文本,且模型增量產生新的文本時,服務端將返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.text.delta。 deltastring 返回的增量文本。 response_idstring 回複的ID。 item_idstring 訊息項ID,可以關聯同一個訊息項。 output_indexinteger 響應中輸出項的索引, 目前固定為 0。 content_indexinteger 響應中輸出項中內部部分的索引, 目前固定為 0。 | {
"delta": "喂",
"event_id": "event_TH49MauuPmRo1RGaMSlP7",
"type": "response.text.delta",
"response_id": "resp_PrRSvPVpnCExdUOGHHLuP",
"item_id": "item_L8IRm9kRXFpxoOjDqDC96",
"output_index": 0,
"content_index": 0
}
|
response.text.done
當輸出模態僅包含文本,且模型產生的文本結束時,服務端將返回此事件。
當響應中斷、不完整或取消時,也會返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.text.done。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 響應輸出項的索引。 content_indexinteger 響應輸出項的索引。 text string 模型輸出的完整文本。 | {
"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 接入時,當輸出模態包含音訊,且模型增量生成新的音訊資料時,服務端返回此事件。WebRTC 接入時,音訊透過 RTP 音訊軌道傳輸,不返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.audio.delta。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 響應輸出項的索引。 content_indexinteger 響應輸出項的索引。 delta string 模型增量輸出的音頻資料,使用Base64編碼。 | {
"event_id": "event_B1osWMZBtrEQbiIwW0qHQ",
"type": "response.audio.delta",
"response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
"item_id": "item_OFaPGtzfWCPyGzxnuEX9i",
"output_index": 0,
"content_index": 0,
"delta": "{base64 audio}"
}
|
response.audio.done
當輸出模態包含音頻,且模型完成組建音頻資料時,服務端將返回此事件。
當響應中斷、不完整或取消時,也會返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.audio.done。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 響應輸出項的索引。 content_indexinteger 響應輸出項的索引。 | {
"event_id": "event_Le1TDl7VfyHQxl47DtGxI",
"type": "response.audio.done",
"response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
"item_id": "item_Ls6MtCUWO7LM4E59QziNv",
"output_index": 0,
"content_index": 0
}
|
response.audio_transcript.delta
當輸出模態包含音頻,且模型增量產生新的音頻對應的文本時,服務端將返回 response.audio_transcript.delta 事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.audio_transcript.delta。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 響應輸出項的索引。 content_indexinteger 響應輸出項的索引。 deltastring 增量文本。 | {
"event_id": "event_BksW7fOwnyavZdDxIzZYM",
"type": "response.audio_transcript.delta",
"response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
"item_id": "item_Ls6MtCUWO7LM4E59QziNv",
"output_index": 0,
"content_index": 0,
"delta": "有什麼"
}
|
response.audio_transcript.done
當輸出模態包含音頻,且模型完成音頻轉錄後,服務端將返回 response.audio_transcript.done 事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.audio_transcript.done。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 響應輸出項的索引。 content_indexinteger 響應輸出項的索引。 transcriptstring 完整文本。 | {
"event_id": "event_X49tL2WerT4WjxcmH16lS",
"type": "response.audio_transcript.done",
"response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
"item_id": "item_Ls6MtCUWO7LM4E59QziNv",
"output_index": 0,
"content_index": 0,
"transcript": "你好呀!有什麼我可以幫你的嗎?"
}
|
response.function_call_arguments.delta
當模型以流式方式產生函數調用的參數字串時,每產生一段新內容,服務端推送一次本事件。用戶端應按接收順序將各事件中的 delta 欄位拼接,得到與當前進度一致的參數文本;完整內容以隨後的 response.function_call_arguments.done 為準。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.function_call_arguments.delta。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 該響應中輸出項的索引。 call_idstring 本次函數調用的唯一 ID,與同一輪中的 done 事件保持一致。 deltastring 本段新增的參數字串片段(增量)。需按順序拼接。 | {
"event_id": "event_SlKoJyEbPEqLq14DSM1u5",
"type": "response.function_call_arguments.delta",
"response_id": "resp_JnTOsWXlFhKcFohZbtfz6",
"item_id": "item_Rhcms7CauTNsQprV5S4Hr",
"output_index": 0,
"call_id": "call_2be200f4cafe419b9530dd",
"delta": " {\"location\": \"北京\"}"
}
|
response.function_call_arguments.done
函數調用參數已全部產生完畢。本事件中的 arguments 為完整的參數字串。用戶端可在收到本事件後解析參數並調用本地工具函數;應以本事件中的完整 arguments 為準,而非 delta 拼接結果。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.function_call_arguments.done。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 該響應中輸出項的索引。 call_idstring 本次函數調用的唯一 ID。 namestring 被調用的函數名稱。 argumentsstring 函數調用的完整參數,一般以 JSON 字串形式表示。 | {
"event_id": "event_X6suLyuL5agdH7r6koesM",
"type": "response.function_call_arguments.done",
"response_id": "resp_JnTOsWXlFhKcFohZbtfz6",
"item_id": "item_Rhcms7CauTNsQprV5S4Hr",
"output_index": 0,
"name": "get_current_weather",
"call_id": "call_2be200f4cafe419b9530dd",
"arguments": " {\"location\": \"北京\"}"
}
|
response.output_item.added
在響應產生過程中建立新專案時,服務端返回此事件。項目類型可以是 message(常規訊息)或 function_call(工具調用)。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.output_item.added。 response_idstring 響應的ID。 output_indexinteger 響應輸出項的索引。 itemobject 輸出項資訊。 屬性 idstring 輸出項的唯一ID。 objectstring 始終為 realtime.item 。 statusstring 輸出項的狀態。 rolestring 發送訊息的角色。 contentstring 訊息的內容。當 type 為 message 時存在。 typestring 輸出項的類型。可選值為 message(常規訊息)或 function_call(工具調用)。 namestring 當 type 為 function_call 時,被調用的函數名稱。 call_idstring 當 type 為 function_call 時,本次函數調用的唯一 ID。 argumentsstring 當 type 為 function_call 時,函數調用的參數(JSON 字串)。在 added 事件中初始為空白字串。 | {
"event_id": "event_DsCO341DEVtiATtCB6BUY",
"type": "response.output_item.added",
"response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
"output_index": 0,
"item": {
"id": "item_Ls6MtCUWO7LM4E59QziNv",
"object": "realtime.item",
"type": "message",
"status": "in_progress",
"role": "assistant",
"content": []
}
}
// 工具調用情境
{
"event_id": "event_HXmKt5pGoiRtXx7Hq7zpN",
"type": "response.output_item.added",
"response_id": "resp_TucN5QgymL5MA8vkJvFlS",
"output_index": 0,
"item": {
"id": "item_FEG9qJGNkPcdf4et3p7BV",
"object": "realtime.item",
"type": "function_call",
"status": "in_progress",
"call_id": "call_bc0a7fb7235840f69ecfe4",
"name": "get_current_weather",
"arguments": ""
}
}
|
response.output_item.done
當新的專案輸出完成時,服務端返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.output_item.done。 response_idstring 響應的ID。 output_indexinteger 響應輸出項的索引。 itemobject 輸出項資訊。 屬性 idstring 輸出項的唯一ID。 objectstring 始終為 realtime.item 。 statusstring 輸出項的狀態。 rolestring 發送訊息的角色。 contentstring 訊息的內容。當 type 為 message 時存在。 typestring 輸出項的類型。可選值為 message(常規訊息)或 function_call(工具調用)。 namestring 當 type 為 function_call 時,被調用的函數名稱。 call_idstring 當 type 為 function_call 時,本次函數調用的唯一 ID。 argumentsstring 當 type 為 function_call 時,函數調用的完整參數(JSON 字串)。 | {
"event_id": "event_MEu5nlLw1LsOguHiehIP8",
"type": "response.output_item.done",
"response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
"output_index": 0,
"item": {
"id": "item_Ls6MtCUWO7LM4E59QziNv",
"object": "realtime.item",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "audio",
"text": "你好呀!有什麼我可以幫你的嗎?"
}
]
}
}
// 工具調用情境
{
"event_id": "event_FHspdfAnCyjuME3mmAwSY",
"type": "response.output_item.done",
"response_id": "resp_TucN5QgymL5MA8vkJvFlS",
"output_index": 0,
"item": {
"id": "item_FEG9qJGNkPcdf4et3p7BV",
"object": "realtime.item",
"type": "function_call",
"status": "completed",
"call_id": "call_bc0a7fb7235840f69ecfe4",
"name": "get_current_weather",
"arguments": " {\"location\": \"杭州\"}"
}
}
|
response.content_part.added
在響應產生過程中,向助手訊息項中添加新內容部分時,服務端返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.content_part.added。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 響應輸出項的索引,目前固定為 0。 content_indexinteger 響應輸出項中內部部分的索引, 目前固定為 0。 partobject 輸出項資訊。 屬性 typestring 內容部分的類型。 textstring 內容部分的文本。 | {
"event_id": "event_AVBOmrgY3C8bjlRajfSUT",
"type": "response.content_part.added",
"response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
"item_id": "item_Ls6MtCUWO7LM4E59QziNv",
"output_index": 0,
"content_index": 0,
"part": {
"type": "audio",
"text": ""
}
}
|
response.content_part.done
在助手訊息項中的內容部分完成串流時,服務端返回此事件。
event_idstring 本次事件唯一識別碼。 typestring 事件類型,固定為response.content_part.done。 response_idstring 響應的ID。 item_idstring 訊息項ID。 output_indexinteger 響應輸出項的索引,目前固定為 0。 content_indexinteger 該項內容數組中內容部分的索引,目前固定為 0。 partobject 輸出項資訊。 屬性 typestring 內容部分的類型。 textstring 內容部分的文本。 | {
"event_id": "event_Il8HD19v58Qr5IBkw7LtN",
"type": "response.content_part.done",
"response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
"item_id": "item_Ls6MtCUWO7LM4E59QziNv",
"output_index": 0,
"content_index": 0,
"part": {
"type": "audio",
"text": "你好呀!有什麼我可以幫你的嗎?"
}
}
|