全部產品
Search
文件中心

Alibaba Cloud Model Studio:服務端事件

更新時間:Feb 05, 2026

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

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

error

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

event_id string

服務端事件ID。

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

type string

事件類型,固定為error

error object

錯誤詳情。

屬性

code string

錯誤碼。

message string

錯誤資訊。

session.created

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

event_id string

服務端事件ID。

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

type string

事件類型,固定為session.created

session object

會話配置。

屬性

id string

會話ID。

object string

會話服務名。

mode string

互動模式,server_commitcommit

model string

使用的模型。

voice string

使用的音色。

response_format string

音頻格式。

sample_rate integer

音頻採樣率。

session.updated

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

event_id string

服務端事件ID。

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

type string

事件類型,固定為session.updated

session object

會話配置。

屬性

id string

會話ID。

object string

會話服務名。

mode string

互動模式,server_commitcommit

model string

使用的模型。

voice string

使用的音色。

response_format string

音頻格式。

sample_rate integer

音頻採樣率。

language_type string

音頻語種。

input_text_buffer.committed

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

event_id string

服務端事件ID。

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

type string

事件類型,固定為input_text_buffer.committed

item_id string

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

input_text_buffer.cleared

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

event_id string

服務端事件ID。

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

type string

事件類型,固定為input_text_buffer.cleared

response.created

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

event_id string

服務端事件ID。

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

type string

事件類型,固定為response.created

response object

響應詳情。

屬性

id string

響應ID。

object string

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

status string

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

  • completed

  • failed

  • in_progress

  • incomplete

voice string

使用的音色。

output array

在此事件下為空白。

response.output_item.added

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

event_id string

服務端事件ID。

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

type string

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

response_id string

響應的ID。

output_index integer

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

item object

輸出項資訊。

屬性

id string

輸出項ID。

object string

始終為 realtime.item

status string

輸出項的狀態。

content array

訊息的內容。

response.content_part.added

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

event_id string

服務端事件ID。

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

type string

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

response_id string

響應的ID。

item_id string

訊息項ID。

output_index integer

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

content_index integer

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

part object

已完成的內容部分。

屬性

type string

內容部分的類型。

text string

內容部分的文本。

response.audio.delta

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

event_id string

服務端事件ID。

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

type string

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

response_id string

響應的ID。

item_id string

訊息項ID。

output_index integer

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

content_index integer

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

delta string

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

response.content_part.done

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

event_id string

服務端事件ID。

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

type string

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

response_id string

響應的ID。

item_id string

訊息項ID。

output_index integer

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

content_index integer

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

part object

已完成的內容部分。

屬性

type string

內容部分的類型。

text string

內容部分的文本。

response.output_item.done

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

event_id string

服務端事件ID。

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

type string

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

response_id string

響應的ID。

output_index integer

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

item object

輸出項資訊。

屬性

id string

輸出項ID。

object string

始終為 realtime.item

status string

輸出項的狀態。

content array

訊息的內容。

response.audio.done

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

event_id string

服務端事件ID。

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

type string

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

response_id string

響應的ID。

item_id string

訊息項ID。

output_index integer

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

content_index integer

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

response.done

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

event_id string

服務端事件ID。

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

Qwen-TTS Realtime

{
  "event_id": "event_xxx",
  "type": "response.done",
  "response": {
    "id": "resp_xxx",
    "object": "realtime.response",
    "conversation_id": "",
    "status": "completed",
    "modalities": [
      "text",
      "audio"
    ],
    "voice": "Cherry",
    "output": [
      {
        "id": "item_FIrYGaNVK3rbIZqeY4QjM",
        "object": "realtime.item",
        "type": "message",
        "status": "completed",
        "role": "assistant",
        "content": [
          {
            "type": "audio",
            "transcript": ""
          }
        ]
      }
    ],
    "usage": {
      "total_tokens": 67,
      "input_tokens": 3,
      "output_tokens": 64,
      "input_tokens_details": {
        "text_tokens": 3
      },
      "output_tokens_details": {
        "text_tokens": 0,
        "audio_tokens": 64
      }
    }
  }
}

type string

事件類型,固定為response.done

response_id string

響應的ID。

response object

響應詳情。

屬性

id string

響應ID。

object string

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

output array

響應的輸出。

usage object

本次語音合成計費資訊。

屬性

characters integer

Qwen3-TTS Realtime計費字元數。

total_tokens integer

Qwen-TTS Realtime輸入和輸出(合成的音頻)內容總長度(Token)。

input_tokens integer

Qwen-TTS Realtime輸入內容總長度(Token)。

output_tokens integer

Qwen-TTS Realtime輸出內容總長度(Token)。

input_tokens_details integer

Qwen-TTS Realtime輸入內容長度(Token)詳情。

input_tokens_details.text_tokens integer

Qwen-TTS Realtime輸入常值內容總長度(Token)。

output_tokens_details integer

Qwen-TTS Realtime輸出內容長度(Token)詳情。

output_tokens_details.text_tokens integer

Qwen-TTS Realtime輸出常值內容總長度(Token)。

output_tokens_details.audio_tokens integer

Qwen-TTS Realtime輸出音頻內容總長度(Token)。

音頻轉換為 Token 的規則:每1秒的音頻對應 50個 Token 。若音頻時間長度不足1秒,則按 50個 Token 計算。

session.finished

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

event_id string

服務端事件ID。

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

type string

事件類型,固定為session.finished