跳转到主要内容
Qwen-Omni-Realtime

Qwen-Omni client events

WebSocket 客户端参考

客户端通过 WebSocket 向服务端发送的事件。
如果不需要实时交互,Qwen-Omni 也支持 Chat API
参考:实时多模态

session.update

连接建立后发送此事件,用于更新会话配置。服务端会校验参数并返回完整配置或错误信息。
Example
{
  "event_id": "event_ToPZqeobitzUJnt3QqtWg",
  "type": "session.update",
  "session": {
    "modalities": ["text", "audio"],
    "voice": "Chelsie",
    "input_audio_format": "pcm16",
    "output_audio_format": "pcm24",
    "instructions": "You are an AI customer service agent for a five-star hotel. Please answer customer inquiries about room types, facilities, prices, and reservation policies accurately and in a friendly manner. Always respond with a professional and helpful attitude. Do not provide unconfirmed information or information beyond the scope of the hotel's services.",
    "turn_detection": {
      "type": "server_vad",
      "threshold": 0.5,
      "silence_duration_ms": 800
    },
    "seed": 1314,
    "max_tokens": 16384,
    "repetition_penalty": 1.05,
    "presence_penalty": 0.0,
    "top_k": 50,
    "top_p": 1.0,
    "temperature": 0.9
  }
}
string
body
必填
事件类型,固定为 session.update
object
body
会话配置。

response.create

通知服务端生成模型响应。在 VAD 模式下,响应会自动生成,无需发送此事件。 服务端依次返回 response.createdresponse.output_item.added,然后是对话项和内容事件(conversation.item.createdresponse.content_part.added),最后是 response.done
Example
{
  "type": "response.create",
  "event_id": "event_1718624400000"
}
string
body
必填
事件类型,固定为 response.create

response.cancel

取消正在进行的响应。如果当前没有响应在进行,则返回错误。
Example
{
  "event_id": "event_B4o9RHSTWobB5OQdEHLTo",
  "type": "response.cancel"
}
string
body
必填
事件类型,固定为 response.cancel

input_audio_buffer.append

向输入音频缓冲区追加音频数据。
Example
{
  "event_id": "event_B4o9RHSTWobB5OQdEHLTo",
  "type": "input_audio_buffer.append",
  "audio": "UklGR..."
}
string
body
必填
事件类型,固定为 input_audio_buffer.append
string
body
必填
Base64 编码的音频数据。

input_audio_buffer.commit

提交输入音频缓冲区作为用户消息。缓冲区为空时返回错误。
  • VAD 模式:自动提交,无需发送此事件。
  • 手动模式:必须发送此事件来创建用户消息。
提交缓冲区不会触发模型响应。服务端返回 input_audio_buffer.committed
如果之前发送了 input_image_buffer.append 事件,input_audio_buffer.commit 会同时提交图像缓冲区和音频缓冲区。
Example
{
  "event_id": "event_B4o9RHSTWobB5OQdEHLTo",
  "type": "input_audio_buffer.commit"
}
string
body
必填
事件类型,固定为 input_audio_buffer.commit

input_audio_buffer.clear

清空音频缓冲区。服务端返回 input_audio_buffer.cleared
Example
{
  "event_id": "event_xxx",
  "type": "input_audio_buffer.clear"
}
string
body
必填
事件类型,固定为 input_audio_buffer.clear

input_image_buffer.append

将图像数据添加到图像缓冲区,支持本地文件或视频流。 限制:
  • 格式:JPG 或 JPEG。推荐 480p 或 720p,最大 1080p。
  • 大小:Base64 编码前不超过 500 KB。
  • 编码:Base64。
  • 频率:每秒最多 1 张图像。
  • 前提:必须先发送至少一个 input_audio_buffer.append 事件。
图像缓冲区通过 input_audio_buffer.commit 事件与音频缓冲区一起提交。
Example
{
  "event_id": "event_xxx",
  "type": "input_image_buffer.append",
  "image": "xxx"
}
string
body
必填
事件类型,固定为 input_image_buffer.append
string
body
必填
Base64 编码的图像数据。