Qwen-Audio Realtime API 的服務端事件參考。所有服務端事件均包含 event_id(服務端自動產生)和 type(事件類型)公用欄位。
使用者指南:即時語音對話(Qwen-Audio-Realtime)。如需瞭解事件互動時序,請參見WebSocket API。
error
說明:請求錯誤或服務異常時返回。用戶端錯誤(invalid_request_error)不中斷串連;服務端錯誤(server_error)將終止串連。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
error 錯誤的詳細資料。 |
session.created
說明:串連建立後服務端發送的首個事件,攜帶會話預設配置。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
session 會話的配置資訊。 |
session.updated
說明:收到 session.update 請求後,若處理成功,則返回此事件,攜帶更新後的完整會話配置;若出錯,則返回 error 事件。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
session 更新後的完整會話配置資訊。結構與 |
input_audio_buffer.speech_started
說明:VAD 檢測到語音開始(server_vad / smart_turn 模式)。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
audio_start_ms 語音開始的時間戳記(毫秒)。 |
|
|
item_id 該段語音最終提交時將建立的 item 的 ID。 |
input_audio_buffer.speech_stopped
說明:VAD 檢測到語音結束(server_vad / smart_turn 模式)。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
audio_end_ms 語音結束的時間戳記(毫秒)。 |
|
|
item_id 將建立的使用者訊息項的 ID。 |
|
|
reason 僅 smart_turn 模式返回此欄位。取值為 |
input_audio_buffer.committed
說明:音頻緩衝已提交為使用者訊息(push-to-talk 的 commit 或 VAD 自動認可)。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
previous_item_id 前一條對話項的 ID。 |
|
|
item_id 建立的使用者訊息項的 ID。 |
input_audio_buffer.cleared
說明:音頻緩衝已清空(僅 push-to-talk 模式)。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
conversation.item.created
說明:新的對話項建立成功。使用者音頻提交、用戶端手動建立或助手響應開始時觸發。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
previous_item_id 前一條對話項的 ID。 |
|
|
item 建立的對話項。 |
conversation.item.deleted
說明:對話項已刪除。用戶端發送 conversation.item.delete 後返回此確認事件。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 已刪除的對話項 ID。 |
conversation.item.retrieved
說明:查詢對話項成功返回。用戶端發送 conversation.item.retrieve 後返回此事件。音訊類型 content 僅包含轉寫文本,不返回原始音頻資料。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item 查詢到的對話項完整資訊。 |
conversation.item.input_audio_transcription.delta
說明:ASR 轉寫增量結果,在語音辨識過程中流式返回。包含情緒和語種檢測資訊。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 關聯的對話項 ID。 |
|
|
content_index 內容部分的索引。 |
|
|
text 已確定的轉寫文本。 |
|
|
stash 尚未確定的暫存文本。 |
conversation.item.input_audio_transcription.completed
說明:ASR 轉寫最終結果。轉寫文本會寫入對應 item 的 transcript 欄位。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 關聯的對話項 ID。 |
|
|
content_index 內容部分的索引。 |
|
|
transcript 完整的轉寫文本。 |
conversation.item.input_audio_transcription.failed
說明:ASR 轉寫失敗。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 關聯的對話項 ID。 |
|
|
content_index 內容部分的索引。 |
|
|
error 錯誤的詳細資料。 |
conversation.item.ambient_audio_transcription.delta
說明:僅 smart_turn 模式。環境音頻轉寫增量結果。當 VAD 檢測到語音活動但語義判定為非有效輪次(如雜訊、“嗯”、“啊”等無語義內容)時,將 ASR 識別結果以 ambient 事件透傳給用戶端。該事件不會關聯到對話上下文中的任何 item,item_id 為獨立產生的臨時 ID。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 獨立產生的臨時 ID,不關聯到對話上下文中的任何 item。 |
|
|
content_index 內容部分的索引。 |
|
|
text 已確定的轉寫文本。 |
|
|
stash 尚未確定的暫存文本。 |
conversation.item.ambient_audio_transcription.completed
說明:僅 smart_turn 模式。環境音頻轉寫最終結果。與 delta 事件配對,表示一段環境音訊轉寫結束。該轉寫結果不會寫入對話上下文。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 獨立產生的臨時 ID,不關聯到對話上下文。 |
|
|
content_index 內容部分的索引。 |
|
|
transcript 完整的轉寫文本。 |
response.created
說明:一輪模型推理開始。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response 響應對象。 |
response.output_item.added
說明:響應中新增一個輸出項。普通回複的輸出項類型為 message;Function Calling 的輸出項類型為 function_call。
|
event_id 本次事件唯一識別碼。 |
Function Call 輸出項樣本: 當輸出項為函數調用時,
說明
一輪響應可包含多個 |
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
item 新增的輸出項。 |
response.content_part.added
說明:輸出項中新增一個內容部分。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
content_index 內容部分在輸出項中的索引。 |
|
|
part 新增的內容部分。 |
response.text.delta
說明:純文字模式下的文本增量事件,流式返迴文本片段。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
content_index 內容部分在輸出項中的索引。 |
|
|
delta 文本增量片段。 |
response.text.done
說明:純文字模式下的文本輸出完成事件。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
content_index 內容部分在輸出項中的索引。 |
|
|
text 完整的文本輸出。 |
response.audio_transcript.delta
說明:音頻模式下的文字字幕增量事件,流式返回字幕片段。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
content_index 內容部分在輸出項中的索引。 |
|
|
delta 字幕增量片段。 |
response.audio_transcript.done
說明:音頻模式下的字幕輸出完成事件。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
content_index 內容部分在輸出項中的索引。 |
|
|
transcript 完整的字幕文本。 |
response.audio.delta
說明:音頻模式下的音頻資料增量事件。delta 欄位為 Base 64 編碼的 PCM 音頻資料。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
content_index 內容部分在輸出項中的索引。 |
|
|
delta Base 64 編碼的 PCM 音頻資料片段。 |
response.audio.done
說明:音頻模式下的音訊輸出完成事件,不包含音頻資料。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
content_index 內容部分在輸出項中的索引。 |
response.content_part.done
說明:輸出項中的內容部分輸出完成。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
content_index 內容部分在輸出項中的索引。 |
|
|
part 完成的內容部分。 |
response.output_item.done
說明:響應中的輸出項輸出完成。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
item 完成的輸出項完整資訊。 |
response.function_call_arguments.delta
說明:Function Calling 參數增量。模型決定調用工具時,服務端會先發送 response.output_item.added(item.type=function_call)和對應的 conversation.item.created,隨後通過本事件流式輸出參數片段。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
call_id 函數調用的唯一識別碼。 |
|
|
delta 函數調用參數的增量片段(JSON 字串片段)。 |
response.function_call_arguments.done
說明:Function Calling 參數輸出完成。收到該事件後,用戶端應執行對應工具,並通過 conversation.item.create 寫入 function_call_output,隨後發送 response.create 觸發二輪推理。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
response_id 關聯的響應 ID。 |
|
|
item_id 關聯的輸出項 ID。 |
|
|
output_index 輸出項在響應中的索引。 |
|
|
call_id 函數調用的唯一識別碼。 |
|
|
name 調用的函數名稱。 |
|
|
arguments 完整的函數調用參數(JSON 字串)。 |
response.done
說明:一輪推理完成。status 表示結束原因。
|
event_id 本次事件唯一識別碼。 |
正常完成
被打斷取消
|
|
type 事件類型,固定為 |
|
|
response 完整的響應對象。 |
voiceprint_audio_list.in_progress
說明:聲紋註冊流程非同步進行中。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 聲紋註冊任務的唯一識別碼。 |
voiceprint_audio_list.completed
說明:聲紋註冊流程已完成。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 聲紋註冊任務的唯一識別碼。 |
voiceprint_audio_list.failed
說明:聲紋註冊失敗,不阻塞正常對話調用。
|
event_id 本次事件唯一識別碼。 |
|
|
type 事件類型,固定為 |
|
|
item_id 聲紋註冊任務的唯一識別碼。 |
|
|
reason 失敗原因描述。 |