跳转到主要内容
实时

Qwen-TTS server events

WebSocket 服务端事件参考

服务端通过 WebSocket 连接发送以下事件。

error

客户端或服务端发生错误时发送。
Example
{
  "event_id": "event_QzAVZRVa9hKqM5VOaHunh",
  "type": "error",
  "error": {
    "code": "invalid_value",
    "message": "Session update error: session already started or finished or failed."
  }
}
string
body
事件 ID。
string
body
固定值 error
object
body
错误详情。

session.created

客户端连接后立即发送,包含默认的会话配置。
Example
{
  "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"
  }
}
string
body
事件 ID。
string
body
固定值 session.created
object
body
会话配置。

session.updated

服务端处理 session.update 请求后发送。如果处理失败,服务端会发送 error 事件。
Example
{
  "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
  }
}
string
body
事件 ID。
string
body
固定值 session.updated
object
body
会话配置。

input_text_buffer.committed

服务端收到 input_text_buffer.commit 事件后发送。
Example
{
  "event_id": "event_FC6MA88wS2oEeXkPvWsxX",
  "type": "input_text_buffer.committed",
  "item_id": ""
}
string
body
事件 ID。
string
body
固定值 input_text_buffer.committed
string
body
待创建的用户消息项 ID。

input_text_buffer.cleared

服务端收到 input_text_buffer.clear 事件后发送。
Example
{
  "event_id": "event_1122",
  "type": "input_text_buffer.cleared"
}
string
body
事件 ID。
string
body
固定值 input_text_buffer.cleared

response.created

服务端收到 input_text_buffer.commit 事件后发送。
Example
{
  "event_id": "event_IMnLqDvG6Ahhk7sWV2uOs",
  "type": "response.created",
  "response": {
    "id": "resp_USvBwHktHcz76r6GaIJUV",
    "object": "realtime.response",
    "conversation_id": "",
    "status": "in_progress",
    "voice": "Cherry",
    "output": []
  }
}
string
body
事件 ID。
string
body
固定值 response.created
object
body
响应详情。

response.output_item.added

新的输出项就绪时发送。
Example
{
  "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": []
  }
}
string
body
事件 ID。
string
body
固定值 response.output_item.added
string
body
响应 ID。
integer
body
响应输出项索引,固定值 0
object
body
输出项详情。

response.content_part.added

新的内容分片就绪时发送。
Example
{
  "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": ""
  }
}
string
body
事件 ID。
string
body
固定值 response.content_part.added
string
body
响应 ID。
string
body
消息项 ID。
integer
body
响应输出项索引,固定值 0
integer
body
内容分片索引,固定值 0
object
body
内容分片详情。

response.audio.delta

模型生成音频块时发送。
Example
{
  "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"
}
string
body
事件 ID。
string
body
固定值 response.audio.delta
string
body
响应 ID。
string
body
消息项 ID。
integer
body
响应输出项索引,固定值 0
integer
body
内容分片索引,固定值 0
string
body
Base64 编码的音频数据块。

response.content_part.done

内容分片完成时发送。
Example
{
  "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": ""
  }
}
string
body
事件 ID。
string
body
固定值 response.content_part.done
string
body
响应 ID。
string
body
消息项 ID。
integer
body
响应输出项索引,固定值 0
integer
body
内容分片索引,固定值 0
object
body
已完成的内容分片。

response.output_item.done

输出项完成时发送。
Example
{
  "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": ""
      }
    ]
  }
}
string
body
事件 ID。
string
body
固定值 response.output_item.done
string
body
响应 ID。
integer
body
响应输出项索引,固定值 0
object
body
输出项详情。

response.audio.done

音频生成完成时发送。
Example
{
  "event_id": "event_LZaOHPzXYMUXGBcVkBmKX",
  "type": "response.audio.done",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "item_id": "item_FIrYGaNVK3rbIZqeY4QjM",
  "output_index": 0,
  "content_index": 0
}
string
body
事件 ID。
string
body
固定值 response.audio.done
string
body
响应 ID。
string
body
消息项 ID。
integer
body
响应输出项索引,固定值 0
integer
body
内容分片索引,固定值 0

response.done

响应生成完成时发送。response 对象包含所有输出项,但不包含已发送的原始音频数据。
  • Qwen3-TTS Realtime
  • Qwen-TTS Realtime
Example
{
  "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
    }
  }
}
string
body
事件 ID。
string
body
固定值 response.done
object
body
响应详情。

session.finished

所有响应生成完成时发送。
Example
{
  "event_id": "event_2239",
  "type": "session.finished"
}
string
body
事件 ID。
string
body
固定值 session.finished