胜算云
胜算云 胜算云 文档中心 ↗ 精益社区

Doubao Seed Realtime 1.0 实时音视频通话 WSS

bytedance/doubao-seed-realtime-1.0 — 在同一条 WebSocket 连接上发送语音和图片帧(视频每会话最多 2 FPS),实时接收模型的文本、语音和用量。
实时会话:先 POST /v1/live/sessions 创建会话,再用返回的 live.id 建立 WebSocket 收发信令(见下方WebSocket 实时通道)。

BASE URLhttps://router.shengsuanyun.com/api
认证方式Authorization: Bearer YOUR_API_KEY
仅存 localStorage 🗝 控制台获取 Key → ✓ 已保存

端点列表

WebSocket 实时通道

客户端视角:send 表示客户端发送,receive 表示客户端接收。

所有帧均为 UTF-8 JSON 文本;音频与图片通过 Base64 字符串传递。先发送 session.create,收到 session.created 后发送业务输入;response.cancel 打断回复,session.close 结束会话并继续接收用量直至 session.closed。模型 query 是平台模型名,session.model 是原生版本。视频由 JPEG/PNG 图片帧组成,每会话最多 2 FPS。

接入步骤

  1. 用它拼出下方的 WebSocket 地址发起连接,握手请求头带 Authorization: Bearer 你的 API Key。
  2. 连接成功后先发送 SessionCreate,之后按「消息一览」收发消息。

完整示例

从创建会话到收到服务端消息的最小可运行代码。运行前设置环境变量 SSY_API_KEY,示例中的取值请换成你自己的。

# pip install requests "websockets>=14"
import asyncio
import json
import os

import requests
import websockets

API_KEY = os.environ["SSY_API_KEY"]

# 2. 建立 WebSocket 连接(握手时带 Authorization 头)
WS_URL = (
    f"wss://router.shengsuanyun.com/api/v1/realtime"
    "?model=bytedance%2Fdoubao-seed-realtime-1.0"
)


async def main():
    headers = {"Authorization": f"Bearer {API_KEY}"}
    async with websockets.connect(WS_URL, additional_headers=headers) as ws:
        # 3. 连接后先发 SessionCreate
        await ws.send(json.dumps({
            "type": "session.create",
            "session": {
                "model": "1.3.0.0",
                "audio": {
                    "input": {"format": {"type": "pcm", "rate": 16000}},
                    "output": {
                        "format": {"type": "pcm_s16le", "rate": 24000},
                        "voice": "zh_female_vv_jupiter_bigtts"
                    }
                }
            },
            "extension": {"video": {"frame_format": "JPEG", "frame_rate": 2}}
        }))
        # 4. 持续接收服务端消息(WebSocket ping 由 websockets 自动应答)
        async for raw in ws:
            print(json.loads(raw))


asyncio.run(main())
// Node.js 18+:npm i ws,保存为 live.mjs 后运行 node live.mjs
import WebSocket from "ws";

const API_KEY = process.env.SSY_API_KEY;

// 2. 建立 WebSocket 连接(握手时带 Authorization 头)
const WS_URL = `wss://router.shengsuanyun.com/api/v1/realtime`
  + "?model=bytedance%2Fdoubao-seed-realtime-1.0";
const ws = new WebSocket(WS_URL, {
  headers: { Authorization: `Bearer ${API_KEY}` }
});

ws.on("open", () => {
  // 3. 连接后先发 SessionCreate
  ws.send(JSON.stringify({
    "type": "session.create",
    "session": {
      "model": "1.3.0.0",
      "audio": {
        "input": {"format": {"type": "pcm", "rate": 16000}},
        "output": {
          "format": {"type": "pcm_s16le", "rate": 24000},
          "voice": "zh_female_vv_jupiter_bigtts"
        }
      }
    },
    "extension": {"video": {"frame_format": "JPEG", "frame_rate": 2}}
  }));
});

// 4. 接收服务端消息(WebSocket ping 由 ws 自动应答)
ws.on("message", (raw) => console.log(JSON.parse(raw.toString())));
ws.on("close", (code, reason) => console.log("连接关闭", code, reason.toString()));
ws.on("error", (err) => console.error(err));
# npm i -g wscat
wscat -c "wss://router.shengsuanyun.com/api/v1/realtime?model=bytedance%2Fdoubao-seed-realtime-1.0" \
  -H "Authorization: Bearer $SSY_API_KEY"

# 连上后粘贴 SessionCreate,回车发送:
{"type":"session.create","session":{"model":"1.3.0.0","audio":{"input":{"format":{"type":"pcm","rate":16000}},"output":{"format":{"type":"pcm_s16le","rate":24000},"voice":"zh_female_vv_jupiter_bigtts"}}},"extension":{"video":{"frame_format":"JPEG","frame_rate":2}}}

连接地址

胜算云公开 WebSocket 服务
wss://router.shengsuanyun.com/api/v1/realtime?model=bytedance%2Fdoubao-seed-realtime-1.0

WebSocket 升级;101 仅表示握手成功,不代表业务会话初始化完成。

连接参数

参数位置说明
modelquery必填平台模型 api_name,与原生会话模型/版本不同。(固定值 "bytedance/doubao-seed-realtime-1.0")
Authorization请求头必填Authorization: Bearer <胜算云 API 密钥>。

消息一览

「发送」= 你的程序 → 胜算云,「接收」= 胜算云 → 你的程序;以下消息均为 JSON 文本帧。

消息方向type说明
SessionCreate发送"session.create"创建会话。等待session.created再发送业务音频。
SessionUpdate发送"session.update"更新会话;原生model由所选平台模型固定。
AudioAppend发送"input_audio_buffer.append"UTF-8 JSON 文本帧。
AudioCommit发送"input_audio_buffer.commit"确认本段音频发送完毕,主动触发判停。
AudioMute发送"input_audio_mute.commit"关闭麦克风且停止音频上行时发送。
AudioUnmute发送"input_audio_unmute.commit"恢复麦克风时发送,再按实时节奏发送音频。
Greeting发送"speech_text_buffer.commit"UTF-8 JSON 文本帧。
ReplacementAppend发送"speech_text_buffer.replacement.append"UTF-8 JSON 文本帧。
ReplacementCommit发送"speech_text_buffer.replacement.commit"UTF-8 JSON 文本帧。
ConversationCreate发送"conversation.item.create"UTF-8 JSON 文本帧。
ConversationUpdate发送"conversation.item.update"UTF-8 JSON 文本帧。
ConversationRetrieve发送"conversation.item.retrieve"未指定条目ID时,返回最近20轮完整上下文。
ConversationDelete发送"conversation.item.delete"按整轮删除;指定user或assistant侧ID都会同时删除配对另一侧。
ResponseCancel发送"response.cancel"打断当前回复;继续接收确认和迟到用量,连接可继续使用。
SessionClose发送"session.close"正常结束会话;继续读取到session.closed并处理其前用量。
ImageAppend发送"input_image_buffer.append"每会话最多2 FPS;与音频在同一连接独立按节奏发送。
UnknownClientEvent发送—未来原生事件扩展;保持原帧。已列出事件按其专用schema描述。
SessionCreated接收"session.created"UTF-8 JSON 文本帧。
SessionUpdated接收"session.updated"UTF-8 JSON 文本帧。
SessionClosed接收"session.closed"UTF-8 JSON 文本帧。
AudioCommitted接收"input_audio_buffer.committed"UTF-8 JSON 文本帧。
ResponseCreated接收"response.created"服务端驱动进入SPEAKING状态;ASR字幕事件不控制播放器。
ResponseCanceled接收"response.canceled"打断信号或response.cancel确认;立即停播并清空队列,仍继续接收迟到用量。
ResponseDone接收"response.done"一轮用量也可能作为独立billing-only事件出现;关闭期还可能收到纯时长尾报。
TranscriptStarted接收"conversation.item.input_audio_transcription.started"UTF-8 JSON 文本帧。
TranscriptDelta接收"conversation.item.input_audio_transcription.delta"UTF-8 JSON 文本帧。
TranscriptCompleted接收"conversation.item.input_audio_transcription.completed"UTF-8 JSON 文本帧。
TranscriptFailed接收"conversation.item.input_audio_transcription.failed"UTF-8 JSON 文本帧。
OutputTextDelta接收"response.output_text.delta"UTF-8 JSON 文本帧。
OutputTextDone接收"response.output_text.done"UTF-8 JSON 文本帧。
OutputAudioStarted接收"response.output_audio.started"UTF-8 JSON 文本帧。
OutputAudioDelta接收"response.output_audio.delta"UTF-8 JSON 文本帧。
OutputAudioDone接收"response.output_audio.done"UTF-8 JSON 文本帧。
ConversationAdded接收"conversation.item.added"UTF-8 JSON 文本帧。
ConversationRetrieved接收"conversation.item.retrieved"UTF-8 JSON 文本帧。
ConversationDeleted接收"conversation.item.deleted"UTF-8 JSON 文本帧。
FunctionArgumentsDone接收"response.function_call_arguments.done"UTF-8 JSON 文本帧。
ErrorFrame接收"error"UTF-8 JSON 文本帧。
UnknownServerEvent接收—未来原生事件扩展;保持原帧。已列出事件按其专用schema描述。

发送的消息(你的程序 → 胜算云)

发送SessionCreatetype = "session.create"

创建会话。等待session.created再发送业务音频。

字段类型说明
typestring必填
固定值 "session.create"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
sessionobject必填
session.idstring可选接续历史对话的session/dialog ID;新会话省略。
session.modelstring必填由平台选择的模型固定到对应原生协议版本。
固定值 "1.3.0.0"
session.instructionsstring可选系统提示词。与模型内部SP、历史上下文、FC结果合计上限64K tokens;不是字符上限。
session.audioobject必填
session.audio.inputobject可选
session.audio.input.formatobject可选
session.audio.input.format.typestring可选输入编码。PCM 使用16位小端序单声道采样。
可选值 "pcm" / "speech_opus"
session.audio.input.format.rateinteger可选输入采样率,单位Hz;仅16000。
固定值 16000
session.audio.outputobject必填
session.audio.output.formatobject可选
session.audio.output.format.typestring可选pcm为32位小端序;pcm_s16le为16位小端序;ogg_opus为Ogg/Opus。
可选值 "pcm" / "pcm_s16le" / "ogg_opus"
session.audio.output.format.rateinteger可选输出采样率,单位Hz;仅24000。
固定值 24000
session.audio.output.voicestring必填音色ID;使用已开通、适用于本模型的官方或复刻音色。
session.audio.output.speednumber可选语速调整;-50为0.5倍,100为2倍。
默认 0最小 -50最大 100
session.audio.output.loudnessnumber可选音量调整;-50为0.5倍,100为2倍。
默认 0最小 -50最大 100
session.toolsarray<object>可选Function Calling工具声明。
session.tools[].typestring可选
固定值 "function"
session.tools[].namestring可选函数名。
session.tools[].descriptionstring可选函数用途。
session.tools[].parametersobject可选函数参数的JSON Schema;按原生结构传递。
extensionobject可选创建/更新事件顶层extension;保留未列出的原生扩展字段。
extension.asrobject可选
extension.asr.extraobject可选
extension.asr.extra.enable_asr_twopassboolean可选启用非流式二遍识别能力。
默认 false
extension.asr.extra.boosting_table_idstring可选热词词表ID;需同时启用enable_asr_twopass。
extension.asr.extra.boosting_table_namestring可选热词词表名称;需同时启用enable_asr_twopass。
extension.asr.extra.regex_correct_table_idstring可选正则替换词表ID。
extension.asr.extra.regex_correct_table_namestring可选正则替换词表名称。
extension.asr.extra.contextoneOf可选ASR热词和替换词配置。保留原生字符串或对象,推荐按示例使用对象。
extension.asr.extra.context(结构 1).hotwordsarray<object>可选
extension.asr.extra.context(结构 1).hotwords[].wordstring可选热词文本。
extension.asr.extra.context(结构 1).correct_wordsobject可选原词到替换词的映射。
extension.dialogobject可选
extension.dialog.locationobject可选
extension.dialog.location.longitudenumber可选经度。
extension.dialog.location.latitudenumber可选纬度。
extension.dialog.location.citystring可选
extension.dialog.location.countrystring可选
extension.dialog.location.provincestring可选
extension.dialog.location.districtstring可选
extension.dialog.location.townstring可选
extension.dialog.location.country_codestring可选
extension.dialog.location.addressstring可选
extension.dialog.dialog_contextarray<object>可选初始化历史上下文,按user/assistant成对提供。
extension.dialog.dialog_context[].rolestring可选
可选值 "user" / "assistant"
extension.dialog.dialog_context[].textstring可选
extension.dialog.dialog_context[].timestampinteger可选服务端对话时间戳;不补充未明确的时间单位。
extension.dialog.extraoneOf可选Dialog附加参数。保留原生字符串或对象,推荐按示例使用对象。
extension.dialog.extra(结构 1).strict_auditboolean可选严格审核;false为普通审核。
默认 true
extension.dialog.extra(结构 1).audit_responsestring可选用户query命中安全审核时的自定义回复。
extension.dialog.extra(结构 1).enable_volc_websearchboolean可选启用内置联网搜索;需另行开通对应服务。
默认 false
extension.dialog.extra(结构 1).volc_websearch_typestring可选
可选值 "web_custom_api" / "web_global_api"
extension.dialog.extra(结构 1).volc_websearch_api_keystring可选联网搜索服务密钥;仅在使用此可选功能时配置,不是平台连接密钥。
extension.dialog.extra(结构 1).enable_musicboolean可选启用唱歌;仅适用音色支持,参见官方音色范围。
默认 false
extension.dialog.extra(结构 1).enable_loudness_normboolean可选启用输出响度均衡。
默认 false
extension.dialog.visual_search_configoneOf可选火山图搜配置。保留原生字符串或对象,推荐按示例使用对象。
extension.dialog.visual_search_config(结构 1).search_typestring可选不启用时省略配置或使用空值;启用时仅web_global_api。
可选值 "" / "web_global_api"
extension.dialog.visual_search_config(结构 1).search_api_keystring可选已开通图搜服务的密钥;不是平台连接密钥。
extension.ttsobject可选
extension.tts.extraobject可选
extension.tts.extra.max_length_to_filter_parenthesisinteger可选括号内文本过滤长度,单位字符;推荐0至100(推荐范围不是硬性上限)。
默认 0
extension.tts.extra.explicit_dialectstring可选仅受支持的音色可用。
可选值 "dongbei" / "sichuan" / "shaanxi" / "yue" / "beijing" / "henan" / "tianjin" / "shanghai"
extension.tts.extra.aigc_metadataoneOf可选AIGC溯源元信息。保留原生字符串或对象,推荐按示例使用对象。
extension.tts.extra.aigc_metadata(结构 1).enableboolean可选启用隐式水印。
默认 false
extension.tts.extra.aigc_metadata(结构 1).content_producerstring可选
extension.tts.extra.aigc_metadata(结构 1).produce_idstring可选
extension.tts.extra.aigc_metadata(结构 1).content_propagatorstring可选
extension.tts.extra.aigc_metadata(结构 1).propagate_idstring可选
extension.videoobject可选
extension.video.frame_formatstring可选图片实际格式须与声明一致。
可选值 "PNG" / "JPEG"
extension.video.frame_rateoneOf可选服务上限2 FPS;不要配置或发送更高帧率。
示例 · 具体参数与音色按授权替换。
{
  "type": "session.create",
  "session": {
    "model": "1.3.0.0",
    "audio": {
      "input": {
        "format": {
          "type": "pcm",
          "rate": 16000
        }
      },
      "output": {
        "format": {
          "type": "pcm_s16le",
          "rate": 24000
        },
        "voice": "zh_female_vv_jupiter_bigtts"
      }
    }
  },
  "extension": {
    "video": {
      "frame_format": "JPEG",
      "frame_rate": 2
    }
  }
}
发送SessionUpdatetype = "session.update"

更新会话;原生model由所选平台模型固定。

字段类型说明
typestring必填
固定值 "session.update"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
sessionobject必填
session.idstring可选接续历史对话的session/dialog ID;新会话省略。
session.modelstring必填由平台选择的模型固定到对应原生协议版本。
固定值 "1.3.0.0"
session.instructionsstring可选系统提示词。与模型内部SP、历史上下文、FC结果合计上限64K tokens;不是字符上限。
session.audioobject必填
session.audio.inputobject可选
session.audio.input.formatobject可选
session.audio.input.format.typestring可选输入编码。PCM 使用16位小端序单声道采样。
可选值 "pcm" / "speech_opus"
session.audio.input.format.rateinteger可选输入采样率,单位Hz;仅16000。
固定值 16000
session.audio.outputobject必填
session.audio.output.formatobject可选
session.audio.output.format.typestring可选pcm为32位小端序;pcm_s16le为16位小端序;ogg_opus为Ogg/Opus。
可选值 "pcm" / "pcm_s16le" / "ogg_opus"
session.audio.output.format.rateinteger可选输出采样率,单位Hz;仅24000。
固定值 24000
session.audio.output.voicestring必填音色ID;使用已开通、适用于本模型的官方或复刻音色。
session.audio.output.speednumber可选语速调整;-50为0.5倍,100为2倍。
默认 0最小 -50最大 100
session.audio.output.loudnessnumber可选音量调整;-50为0.5倍,100为2倍。
默认 0最小 -50最大 100
session.toolsarray<object>可选Function Calling工具声明。
session.tools[].typestring可选
固定值 "function"
session.tools[].namestring可选函数名。
session.tools[].descriptionstring可选函数用途。
session.tools[].parametersobject可选函数参数的JSON Schema;按原生结构传递。
extensionobject可选创建/更新事件顶层extension;保留未列出的原生扩展字段。
extension.asrobject可选
extension.asr.extraobject可选
extension.asr.extra.enable_asr_twopassboolean可选启用非流式二遍识别能力。
默认 false
extension.asr.extra.boosting_table_idstring可选热词词表ID;需同时启用enable_asr_twopass。
extension.asr.extra.boosting_table_namestring可选热词词表名称;需同时启用enable_asr_twopass。
extension.asr.extra.regex_correct_table_idstring可选正则替换词表ID。
extension.asr.extra.regex_correct_table_namestring可选正则替换词表名称。
extension.asr.extra.contextoneOf可选ASR热词和替换词配置。保留原生字符串或对象,推荐按示例使用对象。
extension.asr.extra.context(结构 1).hotwordsarray<object>可选
extension.asr.extra.context(结构 1).hotwords[].wordstring可选热词文本。
extension.asr.extra.context(结构 1).correct_wordsobject可选原词到替换词的映射。
extension.dialogobject可选
extension.dialog.locationobject可选
extension.dialog.location.longitudenumber可选经度。
extension.dialog.location.latitudenumber可选纬度。
extension.dialog.location.citystring可选
extension.dialog.location.countrystring可选
extension.dialog.location.provincestring可选
extension.dialog.location.districtstring可选
extension.dialog.location.townstring可选
extension.dialog.location.country_codestring可选
extension.dialog.location.addressstring可选
extension.dialog.dialog_contextarray<object>可选初始化历史上下文,按user/assistant成对提供。
extension.dialog.dialog_context[].rolestring可选
可选值 "user" / "assistant"
extension.dialog.dialog_context[].textstring可选
extension.dialog.dialog_context[].timestampinteger可选服务端对话时间戳;不补充未明确的时间单位。
extension.dialog.extraoneOf可选Dialog附加参数。保留原生字符串或对象,推荐按示例使用对象。
extension.dialog.extra(结构 1).strict_auditboolean可选严格审核;false为普通审核。
默认 true
extension.dialog.extra(结构 1).audit_responsestring可选用户query命中安全审核时的自定义回复。
extension.dialog.extra(结构 1).enable_volc_websearchboolean可选启用内置联网搜索;需另行开通对应服务。
默认 false
extension.dialog.extra(结构 1).volc_websearch_typestring可选
可选值 "web_custom_api" / "web_global_api"
extension.dialog.extra(结构 1).volc_websearch_api_keystring可选联网搜索服务密钥;仅在使用此可选功能时配置,不是平台连接密钥。
extension.dialog.extra(结构 1).enable_musicboolean可选启用唱歌;仅适用音色支持,参见官方音色范围。
默认 false
extension.dialog.extra(结构 1).enable_loudness_normboolean可选启用输出响度均衡。
默认 false
extension.dialog.visual_search_configoneOf可选火山图搜配置。保留原生字符串或对象,推荐按示例使用对象。
extension.dialog.visual_search_config(结构 1).search_typestring可选不启用时省略配置或使用空值;启用时仅web_global_api。
可选值 "" / "web_global_api"
extension.dialog.visual_search_config(结构 1).search_api_keystring可选已开通图搜服务的密钥;不是平台连接密钥。
extension.ttsobject可选
extension.tts.extraobject可选
extension.tts.extra.max_length_to_filter_parenthesisinteger可选括号内文本过滤长度,单位字符;推荐0至100(推荐范围不是硬性上限)。
默认 0
extension.tts.extra.explicit_dialectstring可选仅受支持的音色可用。
可选值 "dongbei" / "sichuan" / "shaanxi" / "yue" / "beijing" / "henan" / "tianjin" / "shanghai"
extension.tts.extra.aigc_metadataoneOf可选AIGC溯源元信息。保留原生字符串或对象,推荐按示例使用对象。
extension.tts.extra.aigc_metadata(结构 1).enableboolean可选启用隐式水印。
默认 false
extension.tts.extra.aigc_metadata(结构 1).content_producerstring可选
extension.tts.extra.aigc_metadata(结构 1).produce_idstring可选
extension.tts.extra.aigc_metadata(结构 1).content_propagatorstring可选
extension.tts.extra.aigc_metadata(结构 1).propagate_idstring可选
extension.videoobject可选
extension.video.frame_formatstring可选图片实际格式须与声明一致。
可选值 "PNG" / "JPEG"
extension.video.frame_rateoneOf可选服务上限2 FPS;不要配置或发送更高帧率。
发送AudioAppendtype = "input_audio_buffer.append"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "input_audio_buffer.append"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
audiostring必填原始音频的Base64;PCM建议每20ms 640字节,再编码发送。
示例 · 具体参数与音色按授权替换。
{
  "type": "input_audio_buffer.append",
  "event_id": "client_audio_1",
  "audio": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
}
发送AudioCommittype = "input_audio_buffer.commit"

确认本段音频发送完毕,主动触发判停。

字段类型说明
typestring必填
固定值 "input_audio_buffer.commit"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
发送AudioMutetype = "input_audio_mute.commit"

关闭麦克风且停止音频上行时发送。

字段类型说明
typestring必填
固定值 "input_audio_mute.commit"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
示例 · 具体参数与音色按授权替换。
{
  "type": "input_audio_mute.commit"
}
发送AudioUnmutetype = "input_audio_unmute.commit"

恢复麦克风时发送,再按实时节奏发送音频。

字段类型说明
typestring必填
固定值 "input_audio_unmute.commit"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
示例 · 具体参数与音色按授权替换。
{
  "type": "input_audio_unmute.commit"
}
发送Greetingtype = "speech_text_buffer.commit"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "speech_text_buffer.commit"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
textstring可选指定打招呼文本。
发送ReplacementAppendtype = "speech_text_buffer.replacement.append"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "speech_text_buffer.replacement.append"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
textstring可选流式指定的合成文本。
发送ReplacementCommittype = "speech_text_buffer.replacement.commit"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "speech_text_buffer.replacement.commit"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
textstring可选可选的最后一段指定文本。
发送ConversationCreatetype = "conversation.item.create"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.create"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
itemsoneOf可选
示例 · 具体参数与音色按授权替换。
{
  "type": "conversation.item.create",
  "items": [
    {
      "role": "tool",
      "call_id": "call_1",
      "content": [
        {
          "type": "input_text",
          "text": "系统运行正常。"
        }
      ]
    }
  ]
}
发送ConversationUpdatetype = "conversation.item.update"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.update"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
itemsarray<object>可选
items[].idstring可选
items[].contentarray<object>可选
items[].content[].typestring必填
固定值 "input_text"
items[].content[].textstring必填文本内容。
发送ConversationRetrievetype = "conversation.item.retrieve"

未指定条目ID时,返回最近20轮完整上下文。

字段类型说明
typestring必填
固定值 "conversation.item.retrieve"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
itemsarray<object>可选
items[].idstring可选上下文条目ID。
发送ConversationDeletetype = "conversation.item.delete"

按整轮删除;指定user或assistant侧ID都会同时删除配对另一侧。

字段类型说明
typestring必填
固定值 "conversation.item.delete"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
itemsarray<object>可选
items[].idstring可选上下文条目ID。
发送ResponseCanceltype = "response.cancel"

打断当前回复;继续接收确认和迟到用量,连接可继续使用。

字段类型说明
typestring必填
固定值 "response.cancel"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
示例 · 具体参数与音色按授权替换。
{
  "type": "response.cancel"
}
发送SessionClosetype = "session.close"

正常结束会话;继续读取到session.closed并处理其前用量。

字段类型说明
typestring必填
固定值 "session.close"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
示例 · 具体参数与音色按授权替换。
{
  "type": "session.close"
}
发送ImageAppendtype = "input_image_buffer.append"

每会话最多2 FPS;与音频在同一连接独立按节奏发送。

字段类型说明
typestring必填
固定值 "input_image_buffer.append"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
imagestring必填PNG/JPEG图片的Base64;图片格式须与extension.video.frame_format一致。
frame_idstring可选可选自增帧标识;省略时由服务端补充。
示例 · 具体参数与音色按授权替换。
{
  "type": "input_image_buffer.append",
  "event_id": "client_image_1",
  "frame_id": "frame_1",
  "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNwaDgAAAKEAYEml6crAAAAAElFTkSuQmCC"
}
发送UnknownClientEvent

未来原生事件扩展;保持原帧。已列出事件按其专用schema描述。

字段类型说明
typestring必填
event_idstring可选

接收的消息(胜算云 → 你的程序)

接收SessionCreatedtype = "session.created"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "session.created"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
sessionobject可选
session.idstring可选会话ID,可用于接续历史。
示例 · 具体参数与音色按授权替换。
{
  "type": "session.created",
  "event_id": "server_session_1",
  "session": {
    "id": "dialog_1"
  }
}
接收SessionUpdatedtype = "session.updated"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "session.updated"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
sessionobject可选
接收SessionClosedtype = "session.closed"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "session.closed"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
接收AudioCommittedtype = "input_audio_buffer.committed"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "input_audio_buffer.committed"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
接收ResponseCreatedtype = "response.created"

服务端驱动进入SPEAKING状态;ASR字幕事件不控制播放器。

字段类型说明
typestring必填
固定值 "response.created"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
question_idstring可选可选;不保证每个事件都有。
response_idstring可选可缺失或为空字符串,不应当作接收事件的前置条件。
接收ResponseCanceledtype = "response.canceled"

打断信号或response.cancel确认;立即停播并清空队列,仍继续接收迟到用量。

字段类型说明
typestring必填
固定值 "response.canceled"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
question_idstring可选可选;不保证每个事件都有。
response_idstring可选可缺失或为空字符串,不应当作接收事件的前置条件。
responseobject可选
response.usageobject可选原生用量;字段可能缺失,显式零是有效事实。通常在response.done.response.usage中,保留服务端原结构。
response.usage.total_tokensinteger可选服务端总token。不要假定等于input_tokens+output_tokens。
最小 0
response.usage.input_tokensinteger可选服务端输入token;不要据此猜测缓存是否已包含。
最小 0
response.usage.output_tokensinteger可选服务端输出token。
最小 0
response.usage.input_token_detailsobject可选
response.usage.input_token_details.text_tokensinteger可选输入文本token。
最小 0
response.usage.input_token_details.audio_tokensinteger可选输入音频token。
最小 0
response.usage.input_token_details.image_tokensinteger可选输入图片token。
最小 0
response.usage.input_token_details.cached_tokensinteger可选缓存token总量;包含关系以模型计费约定为准。
最小 0
response.usage.input_token_details.cached_tokens_detailsobject可选
response.usage.input_token_details.cached_tokens_details.text_tokensinteger可选缓存中的文本 token;显式0和缺失不同。
最小 0
response.usage.input_token_details.cached_tokens_details.audio_tokensinteger可选缓存中的音频 token;显式0和缺失不同。
最小 0
response.usage.input_token_details.cached_tokens_details.image_tokensinteger可选缓存中的图片 token;显式0和缺失不同。
最小 0
response.usage.output_token_detailsobject可选
response.usage.output_token_details.text_tokensinteger可选输出文本token。
最小 0
response.usage.output_token_details.audio_tokensinteger可选输出音频token。
最小 0
response.usage.duration_detailsobject可选
response.usage.duration_details.audio_duration_msnumber可选本次上报音频时长,毫秒;保留0,不补齐缺失值。
最小 0
response.usage.duration_details.vision_duration_msnumber可选本次上报视觉时长,毫秒;保留0,不补齐缺失值。
最小 0
usageobject可选原生用量;字段可能缺失,显式零是有效事实。通常在response.done.response.usage中,保留服务端原结构。
usage.total_tokensinteger可选服务端总token。不要假定等于input_tokens+output_tokens。
最小 0
usage.input_tokensinteger可选服务端输入token;不要据此猜测缓存是否已包含。
最小 0
usage.output_tokensinteger可选服务端输出token。
最小 0
usage.input_token_detailsobject可选
usage.input_token_details.text_tokensinteger可选输入文本token。
最小 0
usage.input_token_details.audio_tokensinteger可选输入音频token。
最小 0
usage.input_token_details.image_tokensinteger可选输入图片token。
最小 0
usage.input_token_details.cached_tokensinteger可选缓存token总量;包含关系以模型计费约定为准。
最小 0
usage.input_token_details.cached_tokens_detailsobject可选
usage.input_token_details.cached_tokens_details.text_tokensinteger可选缓存中的文本 token;显式0和缺失不同。
最小 0
usage.input_token_details.cached_tokens_details.audio_tokensinteger可选缓存中的音频 token;显式0和缺失不同。
最小 0
usage.input_token_details.cached_tokens_details.image_tokensinteger可选缓存中的图片 token;显式0和缺失不同。
最小 0
usage.output_token_detailsobject可选
usage.output_token_details.text_tokensinteger可选输出文本token。
最小 0
usage.output_token_details.audio_tokensinteger可选输出音频token。
最小 0
usage.duration_detailsobject可选
usage.duration_details.audio_duration_msnumber可选本次上报音频时长,毫秒;保留0,不补齐缺失值。
最小 0
usage.duration_details.vision_duration_msnumber可选本次上报视觉时长,毫秒;保留0,不补齐缺失值。
最小 0
接收ResponseDonetype = "response.done"

一轮用量也可能作为独立billing-only事件出现;关闭期还可能收到纯时长尾报。

字段类型说明
typestring必填
固定值 "response.done"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
question_idstring可选可选;不保证每个事件都有。
response_idstring可选可缺失或为空字符串,不应当作接收事件的前置条件。
responseobject可选
response.idstring可选
response.usageobject可选原生用量;字段可能缺失,显式零是有效事实。通常在response.done.response.usage中,保留服务端原结构。
response.usage.total_tokensinteger可选服务端总token。不要假定等于input_tokens+output_tokens。
最小 0
response.usage.input_tokensinteger可选服务端输入token;不要据此猜测缓存是否已包含。
最小 0
response.usage.output_tokensinteger可选服务端输出token。
最小 0
response.usage.input_token_detailsobject可选
response.usage.input_token_details.text_tokensinteger可选输入文本token。
最小 0
response.usage.input_token_details.audio_tokensinteger可选输入音频token。
最小 0
response.usage.input_token_details.image_tokensinteger可选输入图片token。
最小 0
response.usage.input_token_details.cached_tokensinteger可选缓存token总量;包含关系以模型计费约定为准。
最小 0
response.usage.input_token_details.cached_tokens_detailsobject可选
response.usage.input_token_details.cached_tokens_details.text_tokensinteger可选缓存中的文本 token;显式0和缺失不同。
最小 0
response.usage.input_token_details.cached_tokens_details.audio_tokensinteger可选缓存中的音频 token;显式0和缺失不同。
最小 0
response.usage.input_token_details.cached_tokens_details.image_tokensinteger可选缓存中的图片 token;显式0和缺失不同。
最小 0
response.usage.output_token_detailsobject可选
response.usage.output_token_details.text_tokensinteger可选输出文本token。
最小 0
response.usage.output_token_details.audio_tokensinteger可选输出音频token。
最小 0
response.usage.duration_detailsobject可选
response.usage.duration_details.audio_duration_msnumber可选本次上报音频时长,毫秒;保留0,不补齐缺失值。
最小 0
response.usage.duration_details.vision_duration_msnumber可选本次上报视觉时长,毫秒;保留0,不补齐缺失值。
最小 0
response.duration_detailsobject可选
response.duration_details.audio_duration_msnumber可选本次上报音频时长,毫秒;保留0,不补齐缺失值。
最小 0
response.duration_details.vision_duration_msnumber可选本次上报视觉时长,毫秒;保留0,不补齐缺失值。
最小 0
usageobject可选原生用量;字段可能缺失,显式零是有效事实。通常在response.done.response.usage中,保留服务端原结构。
usage.total_tokensinteger可选服务端总token。不要假定等于input_tokens+output_tokens。
最小 0
usage.input_tokensinteger可选服务端输入token;不要据此猜测缓存是否已包含。
最小 0
usage.output_tokensinteger可选服务端输出token。
最小 0
usage.input_token_detailsobject可选
usage.input_token_details.text_tokensinteger可选输入文本token。
最小 0
usage.input_token_details.audio_tokensinteger可选输入音频token。
最小 0
usage.input_token_details.image_tokensinteger可选输入图片token。
最小 0
usage.input_token_details.cached_tokensinteger可选缓存token总量;包含关系以模型计费约定为准。
最小 0
usage.input_token_details.cached_tokens_detailsobject可选
usage.input_token_details.cached_tokens_details.text_tokensinteger可选缓存中的文本 token;显式0和缺失不同。
最小 0
usage.input_token_details.cached_tokens_details.audio_tokensinteger可选缓存中的音频 token;显式0和缺失不同。
最小 0
usage.input_token_details.cached_tokens_details.image_tokensinteger可选缓存中的图片 token;显式0和缺失不同。
最小 0
usage.output_token_detailsobject可选
usage.output_token_details.text_tokensinteger可选输出文本token。
最小 0
usage.output_token_details.audio_tokensinteger可选输出音频token。
最小 0
usage.duration_detailsobject可选
usage.duration_details.audio_duration_msnumber可选本次上报音频时长,毫秒;保留0,不补齐缺失值。
最小 0
usage.duration_details.vision_duration_msnumber可选本次上报视觉时长,毫秒;保留0,不补齐缺失值。
最小 0
duration_detailsobject可选
duration_details.audio_duration_msnumber可选本次上报音频时长,毫秒;保留0,不补齐缺失值。
最小 0
duration_details.vision_duration_msnumber可选本次上报视觉时长,毫秒;保留0,不补齐缺失值。
最小 0
示例 · 具体参数与音色按授权替换。
{
  "type": "response.done",
  "event_id": "server_usage_1",
  "response": {
    "usage": {
      "total_tokens": 6983,
      "input_tokens": 3420,
      "output_tokens": 172,
      "input_token_details": {
        "text_tokens": 3366,
        "audio_tokens": 54,
        "image_tokens": 0,
        "cached_tokens": 3391,
        "cached_tokens_details": {
          "text_tokens": 3391,
          "audio_tokens": 0,
          "image_tokens": 0
        }
      },
      "output_token_details": {
        "text_tokens": 47,
        "audio_tokens": 125
      },
      "duration_details": {
        "audio_duration_ms": 6000,
        "vision_duration_ms": 2000
      }
    }
  }
}
示例 · 配套规范示例;示例值仅作结构演示。
{
  "type": "response.done",
  "event_id": "server_zero_1",
  "response": {
    "usage": {
      "total_tokens": 0,
      "input_tokens": 0,
      "output_tokens": 0,
      "input_token_details": {
        "text_tokens": 0,
        "audio_tokens": 0,
        "cached_tokens": 0,
        "cached_tokens_details": {
          "text_tokens": 0,
          "audio_tokens": 0
        }
      },
      "output_token_details": {
        "text_tokens": 0,
        "audio_tokens": 0
      },
      "duration_details": {
        "audio_duration_ms": 0,
        "vision_duration_ms": 0
      }
    }
  }
}
示例 · 配套规范示例;示例值仅作结构演示。
{
  "type": "response.done",
  "event_id": "server_close_usage_1",
  "response": {
    "usage": {
      "total_tokens": 0,
      "input_token_details": {
        "text_tokens": 0,
        "audio_tokens": 0,
        "cached_tokens": 0,
        "cached_tokens_details": {
          "text_tokens": 0,
          "audio_tokens": 0
        }
      },
      "output_token_details": {
        "text_tokens": 0,
        "audio_tokens": 0
      },
      "duration_details": {
        "audio_duration_ms": 829,
        "vision_duration_ms": 0
      }
    }
  }
}
接收TranscriptStartedtype = "conversation.item.input_audio_transcription.started"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.input_audio_transcription.started"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
item_idstring可选
content_indexinteger可选
接收TranscriptDeltatype = "conversation.item.input_audio_transcription.delta"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.input_audio_transcription.delta"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
item_idstring可选
content_indexinteger可选
deltastring可选增量转写文本。
接收TranscriptCompletedtype = "conversation.item.input_audio_transcription.completed"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.input_audio_transcription.completed"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
item_idstring可选
content_indexinteger可选
transcriptstring可选完成的转写文本。
接收TranscriptFailedtype = "conversation.item.input_audio_transcription.failed"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.input_audio_transcription.failed"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
item_idstring可选
content_indexinteger可选
errorobject可选升级后的原生业务错误;不等同于HTTP握手状态码。
error.typestring可选
error.codestring | integer | null可选
error.messagestring可选
error.param可选
接收OutputTextDeltatype = "response.output_text.delta"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "response.output_text.delta"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
question_idstring可选可选;不保证每个事件都有。
response_idstring可选可缺失或为空字符串,不应当作接收事件的前置条件。
deltastring可选模型文本增量。
示例 · 具体参数与音色按授权替换。
{
  "type": "response.output_text.delta",
  "event_id": "server_text_1",
  "delta": "你好。"
}
接收OutputTextDonetype = "response.output_text.done"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "response.output_text.done"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
question_idstring可选可选;不保证每个事件都有。
response_idstring可选可缺失或为空字符串,不应当作接收事件的前置条件。
textstring可选本次完整输出文本。
接收OutputAudioStartedtype = "response.output_audio.started"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "response.output_audio.started"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
question_idstring可选可选;不保证每个事件都有。
response_idstring可选可缺失或为空字符串,不应当作接收事件的前置条件。
tts_typestring可选例如chat_tts_text,也可能为空。
接收OutputAudioDeltatype = "response.output_audio.delta"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "response.output_audio.delta"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
question_idstring可选可选;不保证每个事件都有。
response_idstring可选可缺失或为空字符串,不应当作接收事件的前置条件。
deltastring可选按会话输出编码封装的音频Base64。
接收OutputAudioDonetype = "response.output_audio.done"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "response.output_audio.done"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
question_idstring可选可选;不保证每个事件都有。
response_idstring可选可缺失或为空字符串,不应当作接收事件的前置条件。
status_codestring | integer可选
接收ConversationAddedtype = "conversation.item.added"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.added"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
itemsarray<object>可选
items[].idstring可选
items[].typestring可选
items[].statusstring可选
items[].rolestring可选
items[].call_idstring可选
items[].contentarray<object>可选
items[].content[].typestring可选
items[].content[].textstring可选
status_codeinteger | string可选
messagestring可选
接收ConversationRetrievedtype = "conversation.item.retrieved"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.retrieved"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
itemsarray<object>可选
items[].idstring可选
items[].typestring可选
items[].statusstring可选
items[].rolestring可选
items[].call_idstring可选
items[].contentarray<object>可选
items[].content[].typestring可选
items[].content[].textstring可选
status_codeinteger | string可选
messagestring可选
接收ConversationDeletedtype = "conversation.item.deleted"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "conversation.item.deleted"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
itemsarray<object>可选
items[].idstring可选
items[].typestring可选
items[].statusstring可选
items[].rolestring可选
items[].call_idstring可选
items[].contentarray<object>可选
items[].content[].typestring可选
items[].content[].textstring可选
status_codeinteger | string可选
messagestring可选
接收FunctionArgumentsDonetype = "response.function_call_arguments.done"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "response.function_call_arguments.done"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
itemsarray<object>可选
items[].idstring可选
items[].typestring可选原生实报可能省略此字段。
items[].call_idstring必填回传工具结果时使用同一个标识。
items[].namestring必填声明过的函数名。
items[].argumentsstring必填JSON编码的参数字符串;无参调用可能为"{}"或空字符串。
示例 · 具体参数与音色按授权替换。
{
  "type": "response.function_call_arguments.done",
  "event_id": "server_tool_1",
  "items": [
    {
      "call_id": "call_1",
      "name": "get_status",
      "arguments": "{}"
    }
  ]
}
接收ErrorFrametype = "error"

UTF-8 JSON 文本帧。

字段类型说明
typestring必填
固定值 "error"
event_idstring可选事件标识。客户端可选,建议为每次操作生成不同标识;服务端可能返回。
errorobject可选升级后的原生业务错误;不等同于HTTP握手状态码。
error.typestring可选
error.codestring | integer | null可选
error.messagestring可选
error.param可选
codestring | integer可选
messagestring可选
示例 · 具体参数与音色按授权替换。
{
  "type": "error",
  "event_id": "server_error_1",
  "error": {
    "message": "服务端错误说明,以实际返回为准"
  }
}
接收UnknownServerEvent

未来原生事件扩展;保持原帧。已列出事件按其专用schema描述。

字段类型说明
typestring必填
event_idstring可选
完整的 WebSocket 消息规范,可直接交给 AI Agent 或代码生成工具。