全部產品
Search
文件中心

Alibaba Cloud Model Studio:服務端事件

更新時間:Nov 09, 2025

本文介紹 Qwen-Omni-Realtime API 的服務端事件。

相關文檔:即時多模態

error

服務端返回的錯誤資訊。

event_id string

本次事件唯一識別碼。

{
  "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"
  }
}

type string

事件類型,固定為error

error object

錯誤的詳細資料。

屬性

type string

錯誤類型。

code string

錯誤碼。

message string

錯誤資訊。

param string

與錯誤相關的參數,如session.modalities

session.created

用戶端串連後,服務端返回的第一個事件,包含本次串連的預設配置資訊。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_RdvlSpbBb2ssyBjYrDHjt",
    "type": "session.created",
    "session": {
        "object": "realtime.session",
        "model": "qwen3-omni-flash-realtime",
        "modalities": [
            "text",
            "audio"
        ],
        "voice": "Cherry",
        "input_audio_format": "pcm16",
        "output_audio_format": "pcm24",
        "input_audio_transcription": {
            "model": "gummy-realtime-v1"
        },
        "turn_detection": {
            "type": "server_vad",
            "threshold": 0.5,
            "prefix_padding_ms": 300,
            "silence_duration_ms": 800,
            "create_response": true,
            "interrupt_response": true
        },
        "tools": [],
        "tool_choice": "auto",
        "temperature": 0.8,
        "id": "sess_Ov7GOXoNXhNjlxXtOGKQS"
    }
}

type string

事件類型,固定為session.created

session object

會話的配置資訊。

屬性

object string

固定為realtime.session

model string

使用的模型。

modalities array

模型輸出模態設定。

voice string

模型產生音訊音色。

input_audio_format string

輸入音訊格式,固定為pcm16

output_audio_format string

輸出音訊格式,固定為pcm24

input_audio_transcription object

語音轉錄的配置。

屬性

model string

語音轉錄模型,固定為gummy-realtime-v1

turn_detection object

語音活動檢測(VAD)的配置。

屬性

type string

服務端VAD類型,固定為server_vad

threshold float

VAD檢測閾值。

silence_duration_ms integer

檢測語音停止的靜音期間。

temperature float

模型的溫度參數。

session.updated

收到使用者的 session.update 請求後,若處理成功,則返回此事件;若出錯,則返回 error 事件。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_X1HsXS4b4uptp6yo1LgKd",
    "type": "session.updated",
    "session": {
        "id": "sess_Aih6vAcY5Ddt6jwFx1tCa",
        "object": "realtime.session",
        "model": "qwen3-omni-flash-realtime",
        "modalities": [
            "text",
            "audio"
        ],
        "instructions": "你是個人助理小雲,請你準確且友好地解答使用者的問題,始終以樂於助人的態度回應。",
        "voice": "Cherry",
        "input_audio_format": "pcm16",
        "output_audio_format": "pcm24",
        "input_audio_transcription": {
            "model": "gummy-realtime-v1"
        },
        "turn_detection": {
            "type": "server_vad",
            "threshold": 0.1,
            "prefix_padding_ms": 500,
            "silence_duration_ms": 900,
            "create_response": true,
            "interrupt_response": true
        },
        "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
    }
}

type string

事件類型,固定為session.updated

session object

會話的配置資訊。

屬性

temperature float

模型的溫度參數。

modalities array

模型輸出模態設定。

voice string

模型產生音訊音色。

instructions string

模型的目標與角色。

input_audio_format string

輸入音訊格式,固定為pcm16

output_audio_format string

輸出音訊格式,固定為pcm24

input_audio_transcription object

語音轉錄的配置。

屬性

model string

語音轉錄模型,固定為gummy-realtime-v1

turn_detection object

語音活動檢測(VAD)的配置。

屬性

type string

服務端VAD類型,固定為server_vad

threshold float

VAD檢測閾值。

silence_duration_ms integer

檢測語音停止的靜音期間。

top_pfloat

核採樣的機率閾值。

top_k integer

模型產生過程中,採樣候選集的大小。

max_tokens integer

模型在本次請求返回的最大 Token 數。

repetition_penalty float

控制模型產生時,連續序列中的重複度

presence_penalty float

控制模型在產生內容時的重複度。

seed integer

模型在每次請求時,運行結果一致性程度。

input_audio_buffer.speech_started

在 VAD 模式下,當服務端在音頻緩衝區中檢測到語音開始時,會返回此事件。

若服務端尚未檢測到語音,則每次向緩衝區添加音頻時都可能觸發此事件。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_Pvp8nEhsQuGCQbFJ9x58n",
    "type": "input_audio_buffer.speech_started",
    "audio_start_ms": 3647,
    "item_id": "item_YbAiGvK2H7YaS34o4R6Ba"
}

type string

事件類型,固定為input_audio_buffer.speech_started

audio_start_ms integer

從音頻開始寫入緩衝區到首次檢測到語音所經過的毫秒數。

item_id string

語音停止時將建立的使用者訊息項的 ID。

使用者訊息項用於將使用者輸入追加到對話歷史,供模型後續推理與產生使用。

input_audio_buffer.speech_stopped

在 VAD 模式下,當音頻緩衝區中檢測到語音結束時,服務端會返回此事件。

同時,服務端還會返回一個 conversation.item.created 事件,以建立對應的使用者訊息項。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_UhQiqNVRsgUiq4KUS5Xb5",
    "type": "input_audio_buffer.speech_stopped",
    "audio_end_ms": 4453,
    "item_id": "item_YbAiGvK2H7YaS34o4R6Ba"
}

type string

事件類型,固定為input_audio_buffer.speech_stopped

audio_end_ms integer

語音停止時刻距會話開始經過的毫秒數。

item_id string

將建立的使用者訊息項的 ID。

input_audio_buffer.committed

當輸入音頻緩衝區被提交時返回此事件。

  • 在VAD模式下,當檢測到使用者說話結束時,服務端會自動認可音頻緩衝區並返回此事件。

  • 在 Manual 模式下,當用戶端發送input_audio_buffer.commit事件後,服務端返回此事件。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_Iy6sUzL1nmdFgshFYxJEz",
    "type": "input_audio_buffer.committed",
    "item_id": "item_YbAiGvK2H7YaS34o4R6Ba"
}

type string

事件類型,固定為input_audio_buffer.committed

item_id string

將建立的使用者訊息項的 ID。

input_audio_buffer.cleared

用戶端發送input_audio_buffer.clear事件後,服務端將返回此事件。

event_id string

本次事件唯一識別碼。

{
  "event_id": "event_RoUu4T8yExPMI37GKwaOC",
  "type": "input_audio_buffer.cleared"
}

type string

事件類型,固定為input_audio_buffer.cleared

conversation.item.created

當對話項建立時返回此事件。

event_id string

本次事件唯一識別碼。

{
    "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"
            }
        ]
    }
}

type string

事件類型,固定為conversation.item.created

item object

要添加到對話中的項。

屬性

id string

對話項的唯一ID。

object string

始終為 realtime.item 。

status string

對話項的狀態。

role string

訊息的角色。

content string

訊息的內容。

conversation.item.input_audio_transcription.completed

此事件表示使用者音頻寫入緩衝區後產生的轉錄結果。其轉錄由獨立的語音辨識模型(當前固定為 gummy-realtime-v1)處理。

語音辨識模型產生的轉錄文本可能與 Qwen-Omni-Realtime 模型的理解存在差異,僅供參考。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_FrrZcxiDfTB9LD9p4pVng",
    "type": "conversation.item.input_audio_transcription.completed",
    "item_id": "item_YbAiGvK2H7YaS34o4R6Ba",
    "content_index": 0,
    "transcript": "喂,你好。"
}

type string

事件類型,固定為conversation.item.input_audio_transcription.completed

item_id string

使用者訊息項的 ID。

content_index integer

當前固定為0。

transcript string

轉錄的常值內容。

conversation.item.input_audio_transcription.failed

啟用輸入音頻轉錄後,若使用者音頻轉錄失敗,服務端會返回此事件。此事件獨立於 error 事件,便於用戶端識別。

event_id string

本次事件唯一識別碼。

{
  "type": "conversation.item.input_audio_transcription.failed",
  "item_id": "<item_id>",
  "content_index": 0,
  "error": {
    "code": "<code>",
    "message": "<message>",
    "param": "<param>"
  }
}

type string

事件類型,固定為conversation.item.input_audio_transcription.failed

item_id string

使用者訊息項的 ID。

content_index integer

當前固定為0。

error object

錯誤資訊。

屬性

code string

錯誤碼。

message string

錯誤訊息。

param string

錯誤相關的參數。

response.created

當服務端產生新的模型響應時,會返回此事件。

event_id 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": "pcm24",
        "output": []
    }
}

type string

事件類型,固定為response.created

response object

響應對象。

屬性

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

此事件下目前為空白。

response.done

響應產生完成後,服務端會返回此事件。事件中的 response 對象包含除原始音頻資料外的全部輸出項。

event_id 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": "pcm24",
        "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
            }
        }
    }
}

type string

事件類型,固定為response.done

response object

響應對象。

屬性

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

object string

輸出項的物件類型,當前固定為realtime.item

status string

輸出項的狀態。

role string

輸出項的角色。

content array

輸出項的內容。

屬性

type string

輸出內容的類型。輸出為純文字時,為text;輸出包含音頻時,為audio

text string

輸出的常值內容。

transcript string

音頻轉錄為文字後的內容。

usage object

本次響應的 Token 消耗資訊。

response.text.delta

當輸出模態僅包含文本,且模型增量產生新的文本時,服務端將返回此事件。

event_id string

本次事件唯一識別碼。

{
    "delta": "喂",
    "event_id": "event_TH49MauuPmRo1RGaMSlP7",
    "type": "response.text.delta",
    "response_id": "resp_PrRSvPVpnCExdUOGHHLuP",
    "item_id": "item_L8IRm9kRXFpxoOjDqDC96",
    "output_index": 0,
    "content_index": 0
}

type string

事件類型,固定為response.text.delta

delta string

返回的增量文本。

response_id string

回複的ID。

item_id string

訊息項ID,可以關聯同一個訊息項。

output_index integer

響應中輸出項的索引, 目前固定為 0。

content_index integer

響應中輸出項中內部部分的索引, 目前固定為 0。

response.text.done

當輸出模態僅包含文本,且模型產生的文本結束時,服務端將返回此事件。

當響應中斷、不完整或取消時,也會返回此事件。

event_id 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?"
}

type string

事件類型,固定為response.text.done

response_id string

響應的ID。

item_id string

訊息項ID。

output_indexinteger

響應輸出項的索引。

content_indexinteger

響應輸出項的索引。

text string

模型輸出的完整文本。

response.audio.delta

當輸出模態包含音頻,且模型增量產生新的音頻資料時,服務端將返回此事件。

event_id string

本次事件唯一識別碼。

{
  "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}"
}

type string

事件類型,固定為response.audio.delta

response_id string

響應的ID。

item_id string

訊息項ID。

output_indexinteger

響應輸出項的索引。

content_indexinteger

響應輸出項的索引。

delta string

模型增量輸出的音頻資料,使用Base64編碼。

response.audio.done

當輸出模態包含音頻,且模型完成組建音頻資料時,服務端將返回此事件。

當響應中斷、不完整或取消時,也會返回此事件。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_Le1TDl7VfyHQxl47DtGxI",
    "type": "response.audio.done",
    "response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
    "item_id": "item_Ls6MtCUWO7LM4E59QziNv",
    "output_index": 0,
    "content_index": 0
}

type string

事件類型,固定為response.audio.done

response_id string

響應的ID。

item_id string

訊息項ID。

output_indexinteger

響應輸出項的索引。

content_indexinteger

響應輸出項的索引。

response.audio_transcript.delta

當輸出模態包含音頻,且模型增量產生新的音頻對應的文本時,服務端將返回 response.audio_transcript.delta 事件。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_BksW7fOwnyavZdDxIzZYM",
    "type": "response.audio_transcript.delta",
    "response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
    "item_id": "item_Ls6MtCUWO7LM4E59QziNv",
    "output_index": 0,
    "content_index": 0,
    "delta": "有什麼"
}

type string

事件類型,固定為response.audio_transcript.delta

response_id string

響應的ID。

item_id string

訊息項ID。

output_indexinteger

響應輸出項的索引。

content_indexinteger

響應輸出項的索引。

delta string

增量文本。

response.audio_transcript.done

當輸出模態包含音頻,且模型完成音頻轉錄後,服務端將返回 response.audio_transcript.done 事件。

event_id string

本次事件唯一識別碼。

{
    "event_id": "event_X49tL2WerT4WjxcmH16lS",
    "type": "response.audio_transcript.done",
    "response_id": "resp_HaVOPdbmX6vifiV5pAfJY",
    "item_id": "item_Ls6MtCUWO7LM4E59QziNv",
    "output_index": 0,
    "content_index": 0,
    "transcript": "你好呀!有什麼我可以幫你的嗎?"
}

type string

事件類型,固定為response.audio_transcript.done

response_id string

響應的ID。

item_id string

訊息項ID。

output_indexinteger

響應輸出項的索引。

content_indexinteger

響應輸出項的索引。

transcript string

完整文本。

response.output_item.added

在響應產生過程中建立新專案時,服務端返回此事件。

event_id string

本次事件唯一識別碼。

{
    "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": []
    }
}

type string

事件類型,固定為response.output_item.added

response_id string

響應的ID。

output_indexinteger

響應輸出項的索引。

itemobject

輸出項資訊。

屬性

id string

輸出項的唯一ID。

object string

始終為 realtime.item 。

status string

輸出項的狀態。

role string

發送訊息的角色。

content string

訊息的內容。

response.output_item.done

當新的專案輸出完成時,服務端返回此事件。

event_id string

本次事件唯一識別碼。

{
    "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": "你好呀!有什麼我可以幫你的嗎?"
            }
        ]
    }
}

type string

事件類型,固定為response.output_item.done

response_id string

響應的ID。

output_indexinteger

響應輸出項的索引。

itemobject

輸出項資訊。

屬性

id string

輸出項的唯一ID。

object string

始終為 realtime.item 。

status string

輸出項的狀態。

role string

發送訊息的角色。

content string

訊息的內容。

response.content_part.added

在響應產生過程中,向助手訊息項中添加新內容部分時,服務端返回此事件。

event_id string

本次事件唯一識別碼。

{
    "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": ""
    }
}

type string

事件類型,固定為response.content_part.added

response_id string

響應的ID。

item_id string

訊息項ID。

output_indexinteger

響應輸出項的索引,目前固定為 0。

content_indexinteger

響應輸出項中內部部分的索引, 目前固定為 0。

partobject

輸出項資訊。

屬性

type string

內容部分的類型。

text string

內容部分的文本。

response.content_part.done

在助手訊息項中的內容部分完成串流時,服務端返回此事件。

event_id string

本次事件唯一識別碼。

{
    "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": "你好呀!有什麼我可以幫你的嗎?"
    }
}

type string

事件類型,固定為response.content_part.done

response_id string

響應的ID。

item_id string

訊息項ID。

output_indexinteger

響應輸出項的索引,目前固定為 0。

content_indexinteger

該項內容數組中內容部分的索引,目前固定為 0。

partobject

輸出項資訊。

屬性

type string

內容部分的類型。

text string

內容部分的文本。