全部產品
Search
文件中心

Alibaba Cloud Model Studio:服務端事件

更新時間:Oct 11, 2026

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

相關文檔:即時語音合成-通義千問。

error

不論是遇到用戶端錯誤還是服務端錯誤,服務端都會響應該事件。

event_idstring

服務端事件ID。

typestring

事件類型,固定為error。

errorobject

錯誤詳情。

屬性

codestring

錯誤碼。

messagestring

錯誤資訊。

{
  "event_id": "event_QzAVZRVa9hKqM5VOaHunh",
  "type": "error",
  "error": {
    "code": "invalid_value",
    "message": "Session update error: session already started or finished or failed."
  }
}

session.created

用戶端串連到服務端後,響應的第一個事件,該事件返回時會攜帶服務端對此次串連的預設配置資訊。

event_idstring

服務端事件ID。

typestring

事件類型,固定為session.created。

sessionobject

會話配置。

屬性

idstring

會話ID。

objectstring

會話服務名。

modestring

互動模式,server_commit或commit。

modelstring

使用的模型。

voicestring

使用的音色。

response_formatstring

音頻格式。

sample_rateinteger

音頻採樣率。

{
  "event_id": "event_xxx",
  "type": "session.created",
  "session": {
    "object": "realtime.session",
    "mode": "server_commit",
    "model": "qwen3-tts-flash-realtime",
    "voice": "Cherry",
    "response_format": "pcm",
    "sample_rate": 24000,
    "id": "sess_xxx"
  }
}

session.updated

接收到用戶端的session.update請求並正確處理後返回。如果出現錯誤,則直接返回error事件。

event_idstring

服務端事件ID。

typestring

事件類型,固定為session.updated。

sessionobject

會話配置。

屬性

idstring

會話ID。

objectstring

會話服務名。

modestring

互動模式,server_commit或commit。

modelstring

使用的模型。

voicestring

使用的音色。

response_formatstring

音頻格式。

sample_rateinteger

音頻採樣率。

language_typestring

音頻語種。

{
  "event_id": "event_xxx",
  "type": "session.updated",
  "session": {
    "id": "sess_xxx",
    "object": "realtime.session",
    "model": "qwen3-tts-flash-realtime",
    "voice": "Cherry",
    "language_type": "Chinese",
    "mode": "commit",
    "response_format": "pcm",
    "sample_rate": 24000
  }
}

input_text_buffer.committed

用戶端發送input_text_buffer.commit事件後,服務端的響應事件。

event_idstring

服務端事件ID。

typestring

事件類型,固定為input_text_buffer.committed。

item_idstring

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

{
  "event_id": "event_FC6MA88wS2oEeXkPvWsxX",
  "type": "input_text_buffer.committed",
  "item_id": ""
}

input_text_buffer.cleared

用戶端發送input_audio_buffer.clear事件後,服務端的響應事件。

event_idstring

服務端事件ID。

typestring

事件類型,固定為input_text_buffer.cleared。

{
    "event_id": "event_1122",
    "type": "input_text_buffer.cleared"
}

response.created

用戶端發送input_text_buffer.commit事件後,服務端的響應事件。

event_idstring

服務端事件ID。

typestring

事件類型,固定為response.created。

responseobject

響應詳情。

屬性

idstring

響應ID。

objectstring

物件類型,在此事件下固定為realtime.response。

statusstring

響應的最終狀態,取值範圍:

  • completed
  • failed
  • in_progress
  • incomplete

voicestring

使用的音色。

outputarray

在此事件下為空白。

{
  "event_id": "event_IMnLqDvG6Ahhk7sWV2uOs",
  "type": "response.created",
  "response": {
    "id": "resp_USvBwHktHcz76r6GaIJUV",
    "object": "realtime.response",
    "conversation_id": "",
    "status": "in_progress",
    "voice": "Cherry",
    "output": []
  }
}

response.output_item.added

當新的item項需要輸出時,服務端返回此事件。

event_idstring

服務端事件ID。

typestring

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

response_idstring

響應的ID。

output_indexinteger

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

itemobject

輸出項資訊。

屬性

idstring

輸出項ID。

objectstring

始終為 realtime.item。

statusstring

輸出項的狀態。

contentarray

訊息的內容。

{
  "event_id": "event_INDGnGNulaXCrStd9ZM5X",
  "type": "response.output_item.added",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "output_index": 0,
  "item": {
    "id": "item_FIrYGaNVK3rbIZqeY4QjM",
    "object": "realtime.item",
    "type": "message",
    "status": "in_progress",
    "role": "assistant",
    "content": []
  }
}

response.content_part.added

當新的內容項需要輸出時,服務端返回此事件。

event_idstring

服務端事件ID。

typestring

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

response_idstring

響應的ID。

item_idstring

訊息項ID。

output_indexinteger

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

content_indexinteger

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

partobject

已完成的內容部分。

屬性

typestring

內容部分的類型。

textstring

內容部分的文本。

{
  "event_id": "event_DigZ95MWN36YYyyjcENoq",
  "type": "response.content_part.added",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "item_id": "item_FIrYGaNVK3rbIZqeY4QjM",
  "output_index": 0,
  "content_index": 0,
  "part": {
    "type": "audio",
    "text": ""
  }
}

response.audio.delta

當模型增量產生新的audio資料時,系統會返回伺服器 response.audio.delta 事件。

event_idstring

服務端事件ID。

typestring

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

response_idstring

響應的ID。

item_idstring

訊息項ID。

output_indexinteger

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

content_indexinteger

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

deltastring

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

{
  "event_id": "event_B1osWMZBtrEQbiIwW0qHQ",
  "type": "response.audio.delta",
  "response_id": "resp_B1osWTzBb8hO0WsELHgVP",
  "item_id": "item_B1osWH81fXDoyim1T5fsF",
  "output_index": 0,
  "content_index": 0,
  "delta": "base64 audio"
}

response.content_part.done

當新的內容項輸出完成時,服務端返回此事件。

event_idstring

服務端事件ID。

typestring

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

response_idstring

響應的ID。

item_idstring

訊息項ID。

output_indexinteger

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

content_indexinteger

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

partobject

已完成的內容部分。

屬性

typestring

內容部分的類型。

textstring

內容部分的文本。

{
  "event_id": "event_Vo2YUjlYQJ4colH8nVzkU",
  "type": "response.content_part.done",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "item_id": "item_FIrYGaNVK3rbIZqeY4QjM",
  "output_index": 0,
  "content_index": 0,
  "part": {
    "type": "audio",
    "text": ""
  }
}

response.output_item.done

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

event_idstring

服務端事件ID。

typestring

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

response_idstring

響應的ID。

output_indexinteger

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

itemobject

輸出項資訊。

屬性

idstring

輸出項ID。

objectstring

始終為 realtime.item。

statusstring

輸出項的狀態。

contentarray

訊息的內容。

{
  "event_id": "event_LO6SJRKIQ9NBayyYB8a1A",
  "type": "response.output_item.done",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "output_index": 0,
  "item": {
    "id": "item_FIrYGaNVK3rbIZqeY4QjM",
    "object": "realtime.item",
    "type": "message",
    "status": "completed",
    "role": "assistant",
    "content": [
      {
        "type": "audio",
        "text": ""
      }
    ]
  }
}

response.audio.done

當模型產生audio資料完成時,系統會返回伺服器 response.audio.done 事件。

event_idstring

服務端事件ID。

typestring

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

response_idstring

響應的ID。

item_idstring

訊息項ID。

output_indexinteger

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

content_indexinteger

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

{
  "event_id": "event_LZaOHPzXYMUXGBcVkBmKX",
  "type": "response.audio.done",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "item_id": "item_FIrYGaNVK3rbIZqeY4QjM",
  "output_index": 0,
  "content_index": 0
}

response.done

當響應產生完成時,服務端會返回此事件。該事件中包含的 Response 對象將包含 Response 中的所有輸出項,但不包括已返回的原始音頻資料。

event_idstring

服務端事件ID。

typestring

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

response_idstring

響應的ID。

responseobject

響應詳情。

屬性

idstring

響應ID。

objectstring

物件類型,在此事件下固定為realtime.response。

outputarray

響應的輸出。

usageobject

本次語音合成計費資訊。

屬性

charactersinteger

Qwen3-TTS Realtime計費字元數。

{
    "event_id": "event_Aemy83XqHFFDDSeJIDn6N",
    "type": "response.done",
    "response": {
        "id": "resp_LFeR42yXZ9SxUAeXjmyTz",
        "object": "realtime.response",
        "conversation_id": "",
        "status": "completed",
        "modalities": [
            "text",
            "audio"
        ],
        "voice": "Cherry",
        "output": [
            {
                "id": "item_Ae1lv2XmRljRSG96L8Zm1",
                "object": "realtime.item",
                "type": "message",
                "status": "completed",
                "role": "assistant",
                "content": [
                    {
                        "type": "audio",
                        "transcript": ""
                    }
                ]
            }
        ],
        "usage": {
            "characters": 25
        }
    }
}

session.finished

當所有響應產生完成時,服務端會返回此事件。

event_idstring

服務端事件ID。

typestring

事件類型,固定為session.finished。

{
  "event_id": "event_2239",
  "type": "session.finished"
}