audio-og-realtime-2.1 / audio-og-realtime-2.1mini/audio-og-live-1 / audio-s-realtime-3.0 / audio-gg-3.8-live 五个能力系列,运行时根据客户请求自动选路。wss:// 生产强制、ws:// 仅内网调试。audio / delta 字段。model 参数 | 定位 |
audio-og-realtime-2.1 | 端到端语音对话 · 基础能力。 |
audio-og-realtime-2.1mini | 端到端语音对话 · 轻量型。 |
audio-og-live-1 | 端到端语音对话 · Live 能力 |
audio-s-realtime-3.0 | 端到端语音对话 · 增强能力。 |
audio-gg-3.8-live | 端到端语音对话 · Live 能力(支持图片输入) |
Audio-OG-realtime-2.1 与 audio-og-realtime-2.1 等价),服务端在解析时统一归一为小写。规范值为上表中的小写形式,本文档下同。model 编写分支代码;能力差异由服务端内部屏蔽,不支持的字段会静默忽略或在控制事件上以 error(code=not_supported) 回复,不会中断会话。delegation 模式(responses 模式)需要联系我们开通。timeoutSec 查询参数覆盖,上限120秒。model 时的兜底:服务端根据账号维度的默认路由做兜底,仍未命中时使用 audio-og-realtime-2.1。wss://{host}/ete/v1/{appid}?model=<audio-og-realtime-2.1|audio-og-realtime-2.1mini|audio-og-live-1|audio-s-realtime-3.0|audio-gg-3.8-live>&secretId=<TC3 SecretId>&signature=<TC3-HMAC-SHA256 hex>&timeStamp=<unix 秒>&expired=<unix 秒>&nonce=<随机整数>&timeoutSec=<会话空闲超时秒>&isProxy=<0|1>
参数 | 必填 | 说明 |
appid | 是 | 腾讯云 AppID,十进制无符号整数,随路径 /ete/v1/{appid} 传入。非数字时握手返回 400;必须与 secretId 所属主账号 AppID 一致,否则返回 401 authentication_failed: code=4111。 |
参数 | 必填 | 类型 | 说明 |
secretId | 是 | string | CAM SecretId。 |
signature | 是 | string | |
timeStamp | 是 | int64 | 签名时的当前 UNIX 时间戳(秒)。 |
expired | 是 | int64 | 签名过期时间的 UNIX 时间戳(秒),必须 >= timeStamp 且 >= now,否则返回401 invalid_timestamp。 |
nonce | 是 | string | 随机串(推荐随机整数),参与签名,防重放由 CAM 校验。 |
model | 否 | string | 能力系列别名,见 服务概述。未指定时按账号默认路由兜底。默认模式下握手阶段不校验取值,非法值会在首次 session.update 时返回 error(code=pipeline_init_failed) 并断开连接;isProxy=1 时在握手阶段校验,非法值返回400 invalid_request: unsupported model。 |
timeoutSec | 否 | int | 会话空闲超时(秒),默认30; > 120 时截断为120;<= 0 或非数字时忽略并使用默认值30。 |
resId | 否 | string | 业务侧资源 ID,透传用于对账。 |
isProxy | 否 | string | 协议模式,仅接受 0 / 1,其它值握手返回400 invalid_request: invalid param。0 或不传(默认):本文档描述的统一 Realtime GA 协议。1:原厂协议透传,服务端只做鉴权 / 限流并原样转发消息,见 2.4.1。 |
signature 除外)都会参与签名校验。wss://mps.tencentcloud.com/ete/v1/1301234567?model=audio-s-realtime-3.0&secretId=AKIDzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&signature=8f2c...4b3a&timeStamp=1735012345&expired=1735015945&nonce=8391023472&timeoutSec=60&resId=order_20260826_0001
isProxy=1 时,服务端不再提供统一的 Realtime GA 协议,客户端直接使用各能力系列对应模型的原厂协议收发消息,服务端原样转发。握手阶段的鉴权、账户状态检查、并发连接数限流与默认模式一致(见 第 3 章 / 11.1)。wss://mps.tencentcloud.com/ete/v1/1301234567?model=audio-s-realtime-3.0&isProxy=1&secretId=AKIDzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&signature=8f2c...4b3a&timeStamp=1735012345&expired=1735015945&nonce=8391023472&timeoutSec=60
isProxy 取值 | 行为 |
不传 / 0 | 默认模式,统一 Realtime GA 协议(本文档除本节外的全部内容),行为不变。 |
1 | 原厂协议透传模式(本节)。 |
其它 | 握手返回 400 invalid_request: invalid param。 |
model 的取值与默认模式相同(不传时按账号默认路由兜底),无法识别时握手返回400 invalid_request: unsupported model。audio-og-realtime-2.1、audio-og-realtime-2.1mini、audio-og-live-1、audio-s-realtime-3.0、audio-gg-3.8-live)对上行事件 / 下行事件 / 可变字段 / 多模态输入的支持情况。矩阵列为 model 取值,行为能力点。not_supported:服务端会回 error(code=not_supported),会话不中断。audio-og-realtime-2.1 与 audio-og-realtime-2.1mini 行为完全一致,下表合并为一列。事件 / 能力点 | audio-og-realtime-2.1(mini) | audio-og-live-1 | audio-s-realtime-3.0 | audio-gg-3.8-live |
session.update(首次) | ✅ 建立会话 | ✅ 建立会话 | ✅ 建立会话 | ✅ 建立会话 |
session.update(后续再次发送) | ⚠️ 见下方注 | ⚠️ 同左 | ⚠️ 同左 | ⚠️ 同左 |
input_audio_buffer.append | ✅ | ✅ | ✅ | ✅ |
input_audio_buffer.commit | ✅ | ❌ 无回执(内置 VAD 自动切分)。 | ✅ | ⚠️ 通知尽快结束当前用户输入,无回执。 |
input_audio_buffer.clear | ✅ 清除已送入音频 + 回 cleared。 | ⚠️ 仅回 cleared,已送入的音频不会被清除。 | ⚠️ 同左 | ⚠️ 同左 |
response.create(带 instructions) | ✅ 作为本轮生成指令。 | ✅ 让服务端说出该文本。 | ||
response.create(不带 instructions) | ✅ 触发一轮生成。 | ⚠️ 静默 no-op(无回执)。 | ⚠️ 仅在之前追加过 message 时触发回复,否则 no-op。 | |
response.cancel | ✅ | ❌ 无回执(no-op,依赖内置 barge-in)。 | ✅ | |
conversation.item.create – message / function_call_output | ✅ | ✅ | ✅(不回 conversation.item.created)。 | |
conversation.item.create – 含 input_image | ✅ Data URL / HTTP URL / detail | ❌ not_supported | ❌ not_supported | |
conversation.item.retrieve / delete | ✅ | ❌ 无回执 | ✅ | ❌ 无回执 |
conversation.item.truncate | ✅ | ❌ not_supported | ❌ not_supported | ❌ not_supported |
output_audio_buffer.clear | ✅ 取消当前 response + 回 cleared。 | ⚠️ 仅回 cleared(不会打断当前回复)。 | ✅ 同第一列 | ✅ 同 response.cancel + 回 cleared。 |
session.close | ✅ | ✅ | ✅ | ✅ |
transcription_session.update | ❌ not_supported | ❌ not_supported | ❌ not_supported | ❌ not_supported |
其它未知 type | 静默忽略 | 静默忽略 | 静默忽略 | 静默忽略 |
session.update 的实际行为(所有能力一致):会话参数在首次 session.update 时一次性生效,此后再发送的 session.update 不会生效,voice / instructions / tools / delegation 等均不会变更;服务端仍会回一条 session.updated,其内容是客户端历次提交字段的浅合并回显,不代表已生效。唯一的例外是下行音频格式:每次 session.update 都会重新校验 audio.output.format,非法时回 unsupported_output_format 并断开连接。如需变更会话参数,请重新建立连接。事件 | audio-og-realtime-2.1(mini) | audio-og-live-1 | audio-s-realtime-3.0 | audio-gg-3.8-live |
session.updated | ✅ | ✅ | ✅ | ✅ |
input_audio_buffer.speech_started / speech_stopped | ✅ | ❌ 不下发 | ❌ 不下发 | |
input_audio_buffer.committed | ✅ | ❌ 不下发 | ✅ | ⚠️ 不保证下发,同上。 |
input_audio_buffer.cleared | ✅ | ✅ | ✅ | ✅ |
conversation.item.input_audio_transcription.delta | ✅ | ⚠️ 携带 start_ms / end_ms,不带 item_id。 | ✅ | ✅ |
conversation.item.input_audio_transcription.completed | ✅(可能带 usage) | ✅ | ✅(不带 usage;在助手开始回复时下发)。 | |
conversation.item.input_audio_transcription.failed | ❌ 不下发 | ❌ 不下发 | ✅ | ❌ 不下发 |
conversation.item.created | ✅ | ❌ 不下发 | ✅ | ❌ 不下发 |
conversation.item.retrieved / deleted | ✅ | ❌ 不下发 | ✅ | ❌ 不下发 |
response.created | ✅ | ❌ 不下发 | ✅ | |
response.output_item.added / content_part.added | ✅ | ⚠️ 仅 function call 时下发。 | ✅ | ✅ |
response.output_audio.delta | ✅ | ⚠️ 不带 item_id / response_id。 | ✅ | ✅ |
response.output_audio_transcript.delta | ✅ | ⚠️ 携带 start_ms / end_ms,不带 item_id / response_id。 | ✅ | ✅ |
response.output_audio.done / response.output_audio_transcript.done | ✅ | ❌ 不下发 | ✅ | ✅(被打断 / 取消的轮次同样下发)。 |
response.content_part.done / response.output_item.done | ✅ | ⚠️ 仅 function call 时下发。 | ✅ | ✅ |
response.done(含 usage) | ✅ | ⚠️ 仅 responses delegation 下发;client delegation 不下发。 | ✅ | ✅ |
response.function_call_arguments.done | ✅ | ⚠️ 仅 responses delegation。 | ✅ | ✅ |
response.function_call_arguments.delta | ❌ 不下发 | ❌ 不下发 | ❌ 不下发 | ❌ 不下发 |
output_audio_buffer.started | ❌ 不下发 | ❌ 不下发 | ✅ | ❌ 不下发 |
output_audio_buffer.stopped | ✅ | ❌ 不下发 | ✅ | ✅ |
output_audio_buffer.cleared | ✅ | ✅ | ✅ | ✅ |
session.delegation.created | ❌ 不下发 | ❌ 不下发 | ❌ 不下发 | |
session.closed | ✅ 客户端 session.close 后下发。 | ✅ 同左 | ✅ 同左 | ✅ 同左 |
rate_limits.updated / response.output_text.* | ❌ 不下发 | ❌ 不下发 | ❌ 不下发 | ❌ 不下发 |
error | ✅ | ✅ | ✅ | ✅ |
session.update 字段支持(仅首次 session.update 生效)字段 | audio-og-realtime-2.1(mini) | audio-og-live-1 | audio-s-realtime-3.0 | audio-gg-3.8-live |
instructions | ✅ | ✅ | ✅ | ✅ |
audio.output.voice | ⚠️ 需在服务端音色白名单内,否则使用默认音色。 | ✅ 不校验,直接使用。 | ⚠️ 需在内置音色列表内(大小写不敏感),否则使用默认音色。 | |
audio.input.format / audio.output.format | ✅ 同左 | ✅ 同左 | ✅ 同左 | |
audio.input.transcription.language | ✅ | ❌ 静默忽略(自动识别语言)。 | ❌ 静默忽略(自动识别语言)。 | ✅ 推荐 BCP-47(如 zh-CN / en-US)。 |
audio.input.turn_detection(VAD) | ❌ 静默忽略(由服务端配置决定)。 | ❌ 静默忽略(强制启用 VAD)。 | ❌ 静默忽略。 | ❌ 静默忽略(强制启用 VAD)。 |
tools | ✅ | ✅ | ✅ 仅 type=function | |
tool_choice | ❌ 静默忽略 | ❌ 静默忽略(固定 auto) | ❌ 静默忽略 | ❌ 静默忽略 |
audio.output.speed / audio.output.loudness | ❌ 静默忽略 | ❌ 静默忽略 | ✅ | ❌ 静默忽略 |
delegation(client / responses) | ❌ 静默忽略 | ✅ 专属 | ❌ 静默忽略 | ❌ 静默忽略 |
extension(私有扩展 asr / tts / dialog) | ❌ 静默忽略 | ❌ 静默忽略 | ✅ | ❌ 静默忽略 |
能力点 | audio-og-realtime-2.1(mini) | audio-og-live-1 | audio-s-realtime-3.0 | audio-gg-3.8-live |
音频输入 | ✅ | ✅ | ✅ | ✅ |
文本输入 | ✅ | ✅( client delegation 下仅 system / assistant 角色生效)。 | ✅ | ✅ |
图片输入( input_image) | ✅ | ❌ | ❌ | ⚠️ 仅 Data URL(png / jpeg / webp / heic / heif)。 |
response.done.usage | ⚠️ 有用量数据时携带。 | ⚠️ 仅 responses delegation。 | ⚠️ 有用量数据时携带。 | ⚠️ 有用量数据时携带。 |
reasoning_tokens / cache_write_tokens | ⚠️ 适用时存在。 | ⚠️ 仅 responses delegation 且适用时存在。 | ⚠️ 适用时存在。 | ⚠️ 仅 reasoning_tokens,适用时存在。 |
signature 本身外的所有 query 参数都参与签名(按字母升序排列)。这意味着:secretId / timeStamp / expired / nonce 一定参与签名。model / timeoutSec / resId)只要您在 URL 里带上了就必须参与签名;未带则不参与。signature 参数本身不参与签名(作为签名结果放在 URL 上)。session.update 事件传递,与 URL 无关。Step 1: 排序并 URL-encode,构造规范化查询串keys = sort(参与签名的 params keys) // 除 signature 之外的所有 querycanonicalQueryString = keys.map(k => k + '=' + urlEncode(params[k])).join('&')Step 2: 构造规范化请求canonicalRequest ="post" + "\\n"+ "/ete/v1/{appid}" + "\\n"+ canonicalQueryString + "\\n"+ "content-type:application/json; charset=utf-8" + "\\n"+ "host:" + host + "\\n"+ "" + "\\n"+ "content-type;host" + "\\n"Step 3: 构造待签字符串date = UTC(timeStamp) 的 YYYY-MM-DDcredentialScope = date + "/mps/tc3_request"hashedRequest = hex( SHA-256( canonicalRequest ) )stringToSign = "TC3-HMAC-SHA256" + "\\n"+ timeStamp + "\\n"+ credentialScope + "\\n"+ hashedRequestStep 4: 计算派生签名密钥kDate = HMAC-SHA256( date, "TC3" + secretKey )kService = HMAC-SHA256( "mps", kDate )kSigning = HMAC-SHA256( "tc3_request", kService )Step 5: 计算最终签名signature = hex( HMAC-SHA256( stringToSign, kSigning ) ) // 小写 hex
generateSignature() 方法,使用浏览器原生 crypto.subtle API 完成。以下节选核心片段:async function sign(cfg) {const now = Math.floor(Date.now() / 1000);const expired = now + 3600;const params = {// 除 signature 外的所有 query 参数, 均需参与签名model: cfg.model, // 可选; 未传则不放入 paramstimeStamp: String(now),expired: String(expired),nonce: String(Math.floor(Math.random() * 1e10)),secretId: cfg.secretId,timeoutSec: String(cfg.timeoutSec || 30),// 若使用 resId, 也一并放入并参与签名:// resId: cfg.resId,};const path = `/ete/v1/${cfg.appid}`;const keys = Object.keys(params).sort();const canonicalQueryString = keys.map((k) => `${k}=${encodeURIComponent(params[k])}`).join('&');const canonicalRequest = ['post', path, canonicalQueryString,'content-type:application/json; charset=utf-8',`host:${cfg.host}`, '', 'content-type;host', '',].join('\\n');const hashed = await sha256Hex(canonicalRequest);const date = new Date(now * 1000).toISOString().split('T')[0];const scope = `${date}/mps/tc3_request`;const stringToSign = ['TC3-HMAC-SHA256', String(now), scope, hashed].join('\\n');const kDate = await hmacSha256(date, 'TC3' + cfg.secretKey);const kService = await hmacSha256('mps', kDate);const kSigning = await hmacSha256('tc3_request', kService);const signature = bufToHex(await hmacSha256(stringToSign, kSigning));const q = new URLSearchParams(); keys.forEach((k) => q.append(k, params[k]));q.append('signature', signature);return `wss://${cfg.host}${path}?${q.toString()}`;}
func sign(host, appID, secretID, secretKey, model string, timeoutSec int) string {now := time.Now().Unix()expired := now + 3600params := map[string]string{"timeStamp": strconv.FormatInt(now, 10),"expired": strconv.FormatInt(expired, 10),"nonce": strconv.Itoa(rand.Intn(1e9)),"secretId": secretID,"timeoutSec": strconv.Itoa(timeoutSec),}if model != "" {params["model"] = model}keys := make([]string, 0, len(params))for k := range params { keys = append(keys, k) }sort.Strings(keys)parts := make([]string, 0, len(keys))for _, k := range keys {parts = append(parts, k+"="+url.QueryEscape(params[k]))}cqs := strings.Join(parts, "&")path := "/ete/v1/" + appIDcanonical := strings.Join([]string{"post", path, cqs,"content-type:application/json; charset=utf-8","host:" + host, "", "content-type;host", "",}, "\\n")hashed := sha256Hex([]byte(canonical))date := time.Unix(now, 0).UTC().Format("2006-01-02")scope := date + "/mps/tc3_request"stringToSign := strings.Join([]string{"TC3-HMAC-SHA256", strconv.FormatInt(now, 10), scope, hashed,}, "\\n")kDate := hmac256([]byte(date), []byte("TC3"+secretKey))kService := hmac256([]byte("mps"), kDate)kSigning := hmac256([]byte("tc3_request"), kService)signature := hex.EncodeToString(hmac256([]byte(stringToSign), kSigning))q := url.Values{}for k, v := range params { q.Set(k, v) }q.Set("signature", signature)return "wss://" + host + path + "?" + q.Encode()}func sha256Hex(b []byte) string { h := sha256.Sum256(b); return hex.EncodeToString(h[:]) }func hmac256(msg, key []byte) []byte { m := hmac.New(sha256.New, key); m.Write(msg); return m.Sum(nil) }
error 事件,而是拿到一个标准的 HTTP 状态码。见 第 11.1 节。session.update 完成会话初始化,服务端才回一条 session.updated。session.updated 才代表“可以开始送音频”。
{"type": "response.cancel"} 打断当前正在生成的 response。response.done(status 可能为 cancelled)。事件 type | 用途 |
session.update | 更新会话参数(首次调用等价于“完成握手初始化”)。 |
input_audio_buffer.append | 追加一段用户音频(base64 编码)。 |
input_audio_buffer.commit | 手动提交音频缓冲(关闭 server_vad 时使用)。 |
input_audio_buffer.clear | 清空未 commit 的上行音频缓冲。 |
response.create | 主动请求服务端生成一次 response(可携带 instructions 用作打招呼 / 干预回复)。 |
response.cancel | 打断当前正在生成的 response。 |
conversation.item.create | 向会话上下文新增一条 item(含 function_call_output 回传)。 |
conversation.item.retrieve | 请求获取指定 item 详情。 |
conversation.item.delete | 删除指定 item。 |
conversation.item.truncate | 截断已生成的 assistant 音频(部分场景不支持,会回 error(not_supported))。 |
output_audio_buffer.clear | 清空当前 assistant 音频播放缓冲(服务端会同步映射为 response.cancel)。 |
transcription_session.update | 独立 transcription 会话更新(当前不支持,会回 error(not_supported))。 |
session.close | 主动优雅关闭会话,服务端会回 session.closed 携带会话总用量后断开(所有能力均支持,详见 9.4) |
session.update 之前收到的控制事件:response.create / conversation.item.create / retrieve / delete / truncate 回 error(code=session_not_ready);input_audio_buffer.append / commit / response.cancel 静默丢弃;input_audio_buffer.clear / output_audio_buffer.clear 仍回 cleared;session.close 正常执行关闭流程。未知 type 一律静默忽略。session.update{"type": "session.update","session": {"instructions": "你是一个专业的智能助手, 说话简洁友好。","audio": {"input": {"format": { "type": "audio/pcm", "rate": 16000 },"transcription": { "language": "zh" }},"output": {"format": { "type": "audio/pcm", "rate": 24000 },"voice": "xxxxxx","speed": 100,"loudness": 100}},"tools": [{"type": "function","name": "get_current_time","description": "获取当前系统时间","parameters": { "type": "object", "properties": {}, "required": [] }}]}}
字段 | 类型 | 说明 |
session.instructions | string | System instructions,覆盖服务端默认。 |
session.audio.input.format.type | string | |
session.audio.input.format.rate | int | 上行采样率(Hz)。 |
session.audio.input.transcription.language | string | ASR 转写语言(ISO 639-1,如 zh / en / ja)。留空则由服务端自动检测;部分能力基于内建语言自适应,客户端指定值可能会被忽略。 |
session.audio.output.format.type | string | 下行音频格式。 |
session.audio.output.format.rate | int | 下行采样率(Hz)。 |
session.audio.output.voice | string | |
session.audio.output.speed | int | 语速(部分能力支持,不支持时静默忽略)。 |
session.audio.output.loudness | int | 响度(部分能力支持,不支持时静默忽略)。 |
session.tools | array | Function tool 定义,遵循标准 GA Function Tool schema(audio-gg-3.8-live 仅支持 type=function,其它类型被忽略)。 |
session.delegation | string/object/null | |
session.extension | object | 私有扩展字段 {asr, tts, dialog}(仅 audio-s-realtime-3.0 生效,其它能力忽略)。 |
server_vad。客户端在 session.audio.input.turn_detection 里的自定义参数,服务端会尽力适配;具体生效情况以 session.updated.session.audio.input.turn_detection 回执为准。input_audio_buffer.append{"type": "input_audio_buffer.append","audio": "<base64-encoded audio chunk>"}
audio 是一段完整的音频负载,服务端按 session.audio.input.format 声明的格式解码。session.update 之前送入的 append 会被静默丢弃。input_audio_buffer.commit / clear{ "type": "input_audio_buffer.commit" }{ "type": "input_audio_buffer.clear" }
commit 仅在关闭 server_vad 时需要显式调用。clear 用于取消当前未提交的用户音频,无论能力后端是否原生支持,服务端都会回一条 input_audio_buffer.cleared 事件给客户端。response.create / cancel{"type": "response.create","response": {"instructions": "你好, 我是你的智能助手。" // 可选}}{ "type": "response.cancel" }
能力 | 带 response.instructions | 不带 instructions |
audio-og-realtime-2.1(mini) | instructions 作为本轮生成指令(不是逐字朗读)。 | 触发一轮生成。 |
audio-s-realtime-3.0 | 服务端逐字合成该文本(打招呼 / 播报)。 | 静默 no-op,无回执(function call 回传后会自动续接,无需发送)。 |
audio-og-live-1(client delegation) | 服务端让模型说出该文本。 | 回 error(code=not_supported)。 |
audio-og-live-1(responses delegation) | 触发继续生成, instructions 被丢弃。 | 继续生成(function call 回传后必须发送)。 |
audio-gg-3.8-live | instructions 作为一条用户文本输入,模型据此回复(不是逐字朗读)。 | 之前通过 conversation.item.create 追加过 message 时触发回复,否则静默 no-op。 |
response.create 支持的字段(仅 audio-og-realtime-2.1(mini) 支持 instructions 以外的字段):字段 | 类型 | 说明 |
response.instructions | string | 见上表。 |
response.voice | string | 本轮临时覆盖的音色(可选)。 |
response.modalities | []string | 本轮输出模态(可选,标准 GA 语义)。 |
response.metadata | object | 元数据(可选)。 |
conversation.item.create{"type": "conversation.item.create","item": {"type": "message","role": "user","content": [{ "type": "input_text", "text": "帮我查一下深圳今天的天气" }]}}
{"type": "conversation.item.create","item": {"type": "function_call_output","call_id": "call_abc123","output": "2026-08-26 09:30:00"}}
input_text 与 input_image 内容块,可以让模型基于图片回答问题。当前仅 audio-og-realtime-2.1 / audio-og-realtime-2.1mini /audio-gg-3.8-live 支持图片输入,其它 model 收到含 input_image 的 item 会返回 error(code=not_supported)。{"type": "conversation.item.create","item": {"type": "message","role": "user","content": [{ "type": "input_text", "text": "请描述这张图里的关键信息" },{ "type": "input_image", "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRg...","detail": "auto" }]}}
{"type": "conversation.item.create","item": {"type": "message","role": "user","content": [{ "type": "input_text", "text": "帮我识别这张截图里的错误码" },{ "type": "input_image", "image_url": "https://example.com/foo.png","detail": "high" }]}}
字段 | 类型 | 必填 | 说明 |
type | string | 是 | 固定 "input_image"。 |
image_url | string | 是 | Data URL( data:image/{jpeg,png,gif,webp};base64,...)或 HTTP/HTTPS URL。 |
detail | string | 否 | "auto"(默认)/ "low" / "high"。low 定量小 token 快回复;high 分辨率高,识别细节更好,消耗更多 tokens。 |
conversation.item.created。{"type": "response.create"}(因为图片消息不像语音会自动触发 VAD)。response.output_audio.delta / response.output_audio_transcript.delta / response.done。response.done.response.usage.input_tokens 总量;detail=high 的图片 tokens 显著高于 detail=low。input_audio_buffer.append 可并行使用。conversation.item.retrieve / delete / truncate{ "type": "conversation.item.retrieve", "item_id": "item_xxx" }{ "type": "conversation.item.delete", "item_id": "item_xxx" }{ "type": "conversation.item.truncate", "item_id": "item_xxx","content_index": 0, "audio_end_ms": 1500 }
output_audio_buffer.clear{ "type": "output_audio_buffer.clear" }
response.cancel 打断当前 TTS。output_audio_buffer.cleared,客户端据此清空本地音频播放缓冲。事件 type | 触发时机 |
session.updated | 每次收到 session.update 后回显;首次即为握手后的第一条下行事件。 |
error | 参数错误 / 服务后端异常 / 不支持的能力。 |
conversation.item.created | 一条 item 加入会话上下文(服务端确认回执)。 |
conversation.item.retrieved | 响应 conversation.item.retrieve。 |
conversation.item.deleted | 响应 conversation.item.delete。 |
conversation.item.input_audio_transcription.delta | 用户 ASR 增量转写(非稳态)。 |
conversation.item.input_audio_transcription.completed | 用户 ASR 稳态转写(可能携带 usage)。 |
conversation.item.input_audio_transcription.failed | 用户 ASR 转写失败。 |
input_audio_buffer.committed | 用户一句话音频入缓冲(VAD 触发或客户端 commit)。 |
input_audio_buffer.cleared | 响应 input_audio_buffer.clear。 |
input_audio_buffer.speech_started | 服务端 VAD 检测到用户开始说话。 |
input_audio_buffer.speech_stopped | 服务端 VAD 检测到用户停止说话。 |
response.created | 一次 response 开始生成。 |
response.output_item.added | response 内新增一个 output_item( message / function_call)。 |
response.content_part.added | output_item 内新增一个 content part( audio / text)。 |
response.output_audio.delta | 助手音频增量(base64)。 |
response.output_audio.done | 助手音频结束。 |
response.output_audio_transcript.delta | 助手音频伴随文本增量。 |
response.output_audio_transcript.done | 助手音频伴随文本稳态。 |
response.function_call_arguments.done | Function call 参数完整下发(不下发 .delta 增量)。 |
response.content_part.done | content part 结束。 |
response.output_item.done | output_item 结束。 |
response.done | 一次 response 全部结束(可能携带 usage;被打断时 status=cancelled)。 |
output_audio_buffer.started | 服务端开始下发助手音频。 |
output_audio_buffer.stopped | 服务端一段助手音频结束。 |
output_audio_buffer.cleared | 响应客户端 output_audio_buffer.clear。 |
session.delegation.created | |
session.closed |
rate_limits.updated、response.output_text.*、response.function_call_arguments.delta、session.created、conversation.created 当前不会下发。session.updated{"type": "session.updated","event_id": "evt_xxxxxxxx","session": {"id": "sess_xxxxxxxx","type": "realtime","model": "audio-s-realtime-3.0","audio": { "input": {...}, "output": {...} },"instructions": "..."}}
input_audio_buffer.append。session 对象是客户端历次 session.update 中 session 字段的浅合并回显,服务端仅补充 id(会话 ID)、type(固定 realtime)、model 三个字段,不代表实际生效的配置。其中 model 取值规则:客户端在 session.model 中自行传入时原样回显;否则为 URL 参数。model URL 未指定时, model 则显式 audio-og-realtime-2.1——注意此时实际生效的能力可能是账号默认路由选中的其它能力,客户端不要依赖该字段判断实际能力,建议始终在 URL 中显式传 model。{"type": "conversation.item.input_audio_transcription.delta","event_id": "evt_xxx", "item_id": "item_xxx","content_index": 0, "delta": "深圳","start_ms": 1240, "end_ms": 1560}{"type": "conversation.item.input_audio_transcription.completed","event_id": "evt_xxx", "item_id": "item_xxx","content_index": 0, "transcript": "深圳今天天气怎么样","usage": { "type": "duration", "seconds": 2 }}
usage 字段承载本次 ASR 转写的用量(type="duration" + seconds),可用于客户端本地成本观测。目前仅 audio-og-realtime-2.1(mini) 可能携带,其余情况缺省(omitempty);客户端应做字段可选兼容。start_ms / end_ms 是 delta 对应音频在会话时间线上的起止毫秒偏移(以会话开始为零点),仅 audio-og-live-1 携带,且取值为 0 时字段会被省略。该能力下 delta 不带 item_id,服务端也不下发 transcription.completed,客户端需按 start_ms / end_ms 的 gap 自合并完整问话,具体见 9.5。其它能力正常下发 completed,不携带这两个字段。audio-s-realtime-3.0 的 ASR delta 为追加式增量;识别过程中若修正了已识别文字,增量可能为空并被跳过,最终以 completed.transcript 为准。transcription.completed.usage 与 response.done.response.usage(token 用量)是两个独立并列的用量字段:前者按 ASR 音频转写秒数记录,后者按 response 的 token 用量记录,量纲不同不可互相换算。{"type": "response.output_audio.delta","event_id": "evt_xxx","response_id": "resp_xxx","item_id": "item_xxx","output_index": 0, "content_index": 0,"delta": "<base64 pcm16 / opus chunk>"}{"type": "response.output_audio_transcript.delta","event_id": "evt_xxx","response_id": "resp_xxx","item_id": "item_xxx","delta": "深圳"}
audio-og-live-1 下这两个事件不带 response_id / item_id,transcript delta 额外带 start_ms / end_ms,见 9.5。客户端解析时请把 item_id 作可选字段。response.done{"type": "response.done","event_id": "evt_xxx","response": {"id": "resp_xxx","status": "completed","usage": {"total_tokens": 123,"input_tokens": 45,"output_tokens": 78,"input_token_details": {"text_tokens": 20,"audio_tokens": 15,"cached_tokens": 10,"cached_tokens_details": {"text_tokens": 6,"audio_tokens": 4}},"output_token_details": {"text_tokens": 30,"audio_tokens": 48,"reasoning_tokens": 25}}}}
reasoning_tokens(仅具备推理能力的模型会下发)表示本轮回答的推理 tokens,为 output_token_details.text_tokens 的内含子集(不与 text / audio 并列);仅在适用时存在,其它能力下为 0 或缺省。input_token_details.cache_write_tokens 表示提示词缓存首次写入的 tokens(与 cached_tokens 命中互斥)。status 取值:audio-og-realtime-2.1(mini) 为 completed / cancelled / failed /incomplete;audio-s-realtime-3.0 / audio-gg-3.8-live 仅有 completed / cancelled;audio-og-live-1 缺省为 completed。response.usage 承载本轮 response 的 token 用量明细,字段结构对齐标准 Realtime GA;无用量数据时该字段缺省(omitempty)。客户端可用于本地用量观测。error{"type": "error","event_id": "evt_xxx","error": {"type": "invalid_request_error","code": "unsupported_output_format","message": "unsupported opus output rate 44100, allowed: 8000/12000/16000/24000/48000","event_id": "客户端触发本 error 的原事件 event_id"}}
unsupported_output_format /pipeline_init_failed / upstream_send_error / upstream_error / upstream_closed。空闲超时(idle_timeout)时服务端直接关闭连接,客户端通常收不到该 error 事件,应以 WebSocket close 作为判断依据。完整错误码见 11.1。格式( format.type) | 说明 | 允许的采样率 |
pcm / audio/pcm / pcm16 / pcm_s16le / s16le | 16-bit signed LE mono PCM | 任意(推荐 16000) |
opus / audio/opus | 裸 Opus packet(每个 append 携带一个完整 packet) | 8k / 12k / 16k / 24k / 48k |
格式 | 允许的采样率 | 备注 |
pcm | 任意 | 服务端会按需做重采样至客户端声明的采样率。 |
opus | 8k / 12k / 16k / 24k / 48k | 服务端负责编码为裸 Opus packet;每个 response.output_audio.delta.delta 通常对应一个 20 ms Opus 帧。 |
audio/pcm / pcm / pcm16 / pcm_s16le 任一形式声明 PCM;用 audio/opus / opus 声明 Opus。服务端会自动归一化。session.audio.output.format 自动选择最优下行链路(直接透传或服务端重采样 / 格式转换),客户端无感知。
response.create:能力 | 是否需要 | 说明 |
audio-og-realtime-2.1(mini) | 需要 | 标准 GA 语义,回传后发 {"type":"response.create"}。 |
audio-s-realtime-3.0 | 不需要 | 收到工具结果后自动续接;发送空 response.create 无副作用(no-op)。 |
audio-og-live-1(responses delegation) | 需要 | 不会自动续接;多个并行 call 需全部回传后再发一次。 |
audio-og-live-1(client delegation) | — | |
audio-gg-3.8-live | 不需要 | 收到工具结果后自动续接(新的一轮 response);发送空 response.create 无副作用(no-op)。 |
function_call_output 回传后都发送一次不带 instructions 的 response.create,可同时兼容以上能力。response.function_call_arguments.done:{"type": "response.function_call_arguments.done","event_id": "evt_xxx","response_id": "resp_xxx","item_id": "item_xxx","call_id": "call_abc123","name": "get_current_time","arguments": "{}"}
conversation.item.create 回传:{"type": "conversation.item.create","item": {"type": "function_call_output","call_id": "call_abc123","output": "2026-08-26 09:30:00"}}
audio-s-realtime-3.0 一轮触发多个 call 时,服务端会拆成多条 function_call_arguments.done(该能力下事件不带 item_id),每个 call 需分别回传。audio-gg-3.8-live 一轮可能触发多个 call,每个 call 需分别回传;触发 function call 的那一轮会先下发 response.done,续接回复是新一轮 response_idaudio-og-live-1 相比其它能力系列的行为差异与专属协议扩展。事件名与字段结构仍沿用 Realtime GA,但该能力缺少多类边界事件、部分控制事件语义不同,客户端需要按本章做单独适配(主要是按时间戳自行断句、按 delegation 模式处理工具调用与上下文注入)。voice / instructions / tools / delegation 均在首次 session.update 时生效,后续 session.update 不生效(所有能力一致,见2.5.1)。如需变更,请重开会话。事件 | 行为 |
input_audio_buffer.commit | 不支持,无回执(内置 VAD 自动切分轮次)。 |
input_audio_buffer.clear | 仅回 input_audio_buffer.cleared,已送入的音频不会被清除。 |
response.cancel | no-op,无回执(内置 barge-in,用户说话即自动打断)。 |
output_audio_buffer.clear | 仅回 output_audio_buffer.cleared,当前回复不会被打断。 |
response.create | client delegation:带 instructions 时让模型说出该文本,不带时回 not_supported;responses delegation:触发继续生成(instructions 被丢弃)。 |
conversation.item.create | 见 9.3;含 input_image 时回 not_supported。 |
conversation.item.retrieve / delete | 不支持,无回执。 |
conversation.item.truncate | 回 error(code=not_supported)。 |
turn_detection 会被忽略。conversation.item.input_audio_transcription.completed、response.output_audio.done、response.output_audio_transcript.done、speech_started / speech_stopped、input_audio_buffer.committed。用户 ASR delta 与助手 transcript delta 额外携带 start_ms / end_ms(以会话开始为零点的毫秒偏移),客户端按 gap 自行断句,见 9.5。delta 事件不带 item_id / response_id:该能力为连续流模型,没有 item 维度:conversation.item.input_audio_transcription.delta 不带 item_id。response.output_audio_transcript.delta / response.output_audio.delta 不带 item_id / response_id。start_ms / end_ms 自行分组(例如本地生成 client-asr-${serial} / client-llm-${serial})。function_call 相关事件仍携带 item_id / call_id。response.created / response.done:responses delegation:只在整个会话首个助手 delta 到达时下发一次;不下发 response.done。client delegation:response.created,此后不再下发;不下发 response.done。客户端应根据 transcript 时间戳判定每轮回复结束。audio-og-live-1 有两种 delegation 模式,客户端可在首次 session.update 中通过 session.delegation 字段声明。两者的核心区别是是否支持 function call:模式 | function call | 上下文注入 | 适用场景 |
responses | ✅ 模型将工具推理委托给服务端工具推理服务,下发 function_call_arguments.done,客户端执行后回传。 | ❌ | 需要调用外部工具(天气、查询、本地数据)。 |
client | ❌ 不会触发 function call, tools 被忽略。 | ✅ 通过 conversation.item.create(role=system/assistant) | 纯语音对话,背景信息由客户端主动注入。 |
responses 模式需要为账号开通工具推理能力;未配置时首次 session.update 回 error(code=pipeline_init_failed) 并断开连接。responses 模式(需回传工具结果并再发 response.create):
client 模式(无 function call,背景信息由客户端注入):
// 简写{ "type": "session.update", "session": { "delegation": "responses" } }// 原生对象(仅读取 type 字段){ "type": "session.update", "session": { "delegation": { "type": "responses" } } }// 显式 null:强制 client 模式(覆盖账号默认配置){ "type": "session.update", "session": { "delegation": null } }
client 也不是 responses)视为未声明,进入下一级自动决策,不会导致会话拒绝。session.delegation(含显式 null → client)。session.tools 非空 → responses。client。
client 但同时携带了 session.tools:尊重客户端选择走 client,tools 被忽略(仅服务端日志 warn),不阻断会话。responses 但账号未开通工具推理能力:首次 session.update 回 error(code=pipeline_init_failed) 并断开连接;此时建议改用 client 模式或联系管理员开通。responses 模式下 tool_choice 固定为 auto,客户端传入的 tool_choice 被忽略。client 模式下,客户端可以在任意时刻(无需等待服务端请求)通过 conversation.item.create 向模型注入上下文。模型在需要外部信息时会下发session.delegation.created(target=client),客户端可据此补充上下文,但这不是必需的。target=client 的 delegation ID(尚未收到时按会话级上下文注入),客户端无需也无法自行指定 delegation_id(item 中携带该字段会被忽略)。responses 模式下 conversation.item.create 的 item 按标准语义处理(用于 function_call_output 回传等),不做下表的 role 映射。item.role | 语义 | 适用场景 |
system | 静默上下文,模型会用作思考依据但不会主动读出来。 | 注入用户画像、时间地点、外部查询结果等。 |
assistant | 让模型主动说出的一段话。 | 定制开场白、播报事件通知。 |
user / 其他 / 缺省(如 function_call_output) | 忽略,无回执(仅服务端日志)。 | — |
conversation.item.created;文本为空的 item 同样被忽略且无回执。
system 与 assistant 两种 role 的区别:system 是静默注入(模型会思考但不发声),assistant 是主动说出(模型立即用 TTS 合成语音)。item.content 写法// 写法 A: input_text (推荐)"content": [{ "type": "input_text", "text": "..." }]// 写法 B: text"content": [{ "type": "text", "text": "..." }]
text 会被服务端直接拼接为单个字符串(不加分隔符);拼接后超过1800 个字符的部分会被截断(单次注入上限约 500 tokens)。content 中包含 input_image 时整条 item 回 error(code=not_supported)。{"type": "conversation.item.create","item": {"type": "message","role": "system","content": [{ "type": "input_text","text": "用户身份: VIP; 语言偏好: 中文; 回复要简短" }]}}
{"type": "conversation.item.create","item": {"type": "message","role": "assistant","content": [{ "type": "input_text","text": "你好,我是你的 AI 助手,请问有什么可以帮你?" }]}}
{"type": "conversation.item.create","item": {"type": "message","role": "system","content": [{ "type": "input_text","text": "北京当前晴, 25°C, 湿度 40%" }]}}
session.close / session.closed)是本服务的私有扩展,四种能力均支持,放在本章仅为历史原因。session.close,让服务端返回本会话的总用量。ws.close() 无法感知服务端会话级总消耗。session.close{ "type": "session.close" }
audio-og-realtime-2.1(mini) / audio-s-realtime-3.0 / audio-gg-3.8-live:若有进行中的 response,先执行一次 response.cancel(当前回复会被打断),再最多等待 10 秒收到该轮 response.done 以加上最后一轮 usage。audio-og-live-1:等待模型侧结束会话,最多 10 秒(不打断当前回复)。session.closed 事件携带本会话总用量。session.close 到收到 session.closed 最长可能约 10 秒。首次 session.update 之前发送 session.close 也会正常收到 session.closed(用量为 0)。session.closed{"type": "session.closed","event_id": "evt_xxx","reason": "client_request","session_duration_seconds": 87.3,"usage": {"total_tokens": 1488,"input_tokens": 1442,"output_tokens": 46,"input_token_details": {"cached_tokens": 0,"cache_write_tokens": 0},"output_token_details": {"reasoning_tokens": 11}}}
reason:当前固定为 client_request。空闲超时、服务内部异常等服务端主动断开的场景下,session.closed 不会送达客户端,客户端只能观察到 WebSocket close。session_duration_seconds:会话时长(秒)。audio-og-live-1 优先使用模型侧统计的会话时长;其它能力或无该统计时,按上行音频累计时长计算(Opus 上行按解码后的时长)。usage:会话内各轮 response.done.response.usage 的累计值,字段结构与之一致(含 reasoning_tokens / cache_write_tokens 明细)。该字段总是存在;audio-og-live-1的 client delegation 下或从未产生 token 用量时各字段为 0。
session.close 后建议启动一个略大于10秒的定时器(如12秒),超时未收到 session.closed(例如网络异常)则主动 ws.close(),避免 UI 卡住。若业务更在意断开速度而非拿到总用量,可缩短该定时器,代价是可能收不到 session.closed。测试页里的 disconnect() 是这套流程的参考实现(定时器为5秒)。ws.close() 而不发 session.close,服务端无法下发 session.closed,但会话总用量仍会在服务端完整统计;如需获取可携带会话 ID 联系管理员。audio-og-live-1 是"连续流"模型,用户 ASR 与助手 transcript 的 delta 边界只反映音频节奏,不是语义 turn 边界。服务端把每个 delta 携带的 start_ms / end_ms(以会话开始为零点的毫秒偏移)原样下发给客户端,不在服务端合成 .completed / .done 边界事件。audio-og-live-1 下 不下发的事件:conversation.item.input_audio_transcription.completedconversation.item.input_audio_transcription.failedinput_audio_buffer.speech_started / .speech_stoppedinput_audio_buffer.committedresponse.output_audio.doneresponse.output_audio_transcript.donestart_ms / end_ms 、且不带 item_id / response_id 的下行事件:conversation.item.input_audio_transcription.delta(用户 ASR)response.output_audio_transcript.delta(助手文本)response.output_audio.delta(助手音频;带 start_ms / end_ms ,仅不带 ID)start_ms / end_ms 为0时字段会被省略,客户端应按缺省为0处理。{ curItemID, lastEndMs }:curItemID 为当前合成中的 utterance 本地 ID。lastEndMs 为当前 utterance 最后一条 delta 的 end_ms。{ start_ms, end_ms, delta }:curItemID 为空 或 start_ms - lastEndMs > GAP_MS(经验值 600~1000ms):curItemID 对应的 UI 条目标为稳态。curItemID(例如 client-asr-${serial},client-llm-${serial})。delta 追加到 curItemID 的缓冲,刷新 UI 为非稳态;lastEndMs = end_ms。audio-og-realtime-2.1(mini) 与 audio-s-realtime-3.0 仍按标准 Realtime GA 下发完整的 .completed / .done 事件,start_ms / end_ms 不保证存在,客户端应按能力系列分支处理:收到 delta 带 start_ms 则走时间戳断句;否则沿用 .completed / .done 稳态事件驱动。gapMs = 800):handleClientSynthAsrDelta():用户 ASR 断句,生成 client-asr-${serial} 本地 ID。handleClientSynthAssistantDelta():助手文本断句,生成 client-llm-${serial} 本地 ID。start_ms - lastEndMs > gapMs 切换条目,将上一条标为稳态后开启新条目。client / responses 两种模式)audio-og-live-1 的下行时序与 4.2 典型时序 相比有若干关键差异:不下发 transcription.completed / speech_started / speech_stopped / input_audio_buffer.committed / response.output_audio.done / response.output_audio_transcript.done;所有 ASR 与助手 transcript deltastart_ms / end_ms;response.done 行为随 delegation.type 而不同。本节分别给出两种模式的完整时序。session.update 开始的业务流。output_audio.delta 实际为高频事件(相邻间隔 ~200ms),时序中仅画一个 loop 代表这段连续流。response.done 的触发点与 output_audio.delta 的尾包不保证严格有序(服务端不再做 idle 对齐,客户端应容忍 response.done 之后 output_audio.delta 尾包到达,参见 9.5)。client delegation 模式session.delegation.created(target=client),客户端可通过 conversation.item.create(role=system/assistant)回灌。本模式不下发 response.done,response.created 仅在会话首轮下发一次,客户端通过 ASR / assistant transcript 的 start_ms / end_ms 时间戳 gap 自行判定 turn 边界。
responses delegation 模式response.done(含 token usage)。多轮 function_call 场景下每轮独立下发一次 response.done 传 function_call_output 后 function_call_output 必须再发 response.create 才会续接。
维度 | client delegation | responses delegation |
工具推理 | ❌ 无 | ✅ 服务端工具推理服务 |
工具能力 | ❌ 不支持( tools 被忽略) | ✅ 支持 tools + function_call |
上下文注入 | ✅ conversation.item.create(role=system/assistant) | ❌ item 按标准语义处理(用于回传 function_call_output) |
session.delegation.created | target: "client" | target: "responses" |
response.created | 仅会话首轮一次 | 每轮一次 |
response.done 下发 | ❌ 不下发(客户端自行断句) | ✅ 每轮推理完成立即下发 |
Token usage | ❌ 无( session.closed.usage 各字段为 0) | ✅ response.done.response.usage 携带每轮 token |
典型适用场景 | 快速接入、依赖客户端状态的对话 | 需外部工具查询(天气、股价、本地数据) |
turn_detection 被忽略;input_audio_buffer.commit 与 response.cancel 无回执(no-op),由内置 VAD 自动切分轮次与内置 barge-in 处理;output_audio_buffer.clear 只回 cleared,无法打断当前回复。response.create 语义随 delegation 而异:见 9.1。response.done 语义不同:仅 responses delegation 下在每轮推理完成时立即下发,含 token usage;client delegation 下不下发。transcription.completed / speech_started /speech_stopped / input_audio_buffer.committed / response.output_audio.done /response.output_audio_transcript.done 均不下发;ASR / assistant transcript delta 额外携带 start_ms / end_ms,客户端自行断句,见 9.5。session.delegation:client / responses 双模式(见 9.2)。conversation.item.create 在 client 模式下用于上下文注入(见 9.3)。session.delegation.created 下行事件。input_image content 块会直接回 not_supported,不会静默丢弃图片部分后只用文本;需图片能力时请切换到 audio-og-realtime-2.1(mini) 或 audio-gg-3.8-live。upstream_error /upstream_closed 并断开。audio-gg-3.8-live 沿用标准 Realtime GA 事件名、字段结构与 response 生命周期事件(response.created → output_item.added → output_audio.delta → *.done → response.done),按 第 4 章 编写的客户端可以直接接入。本章列出需要关注的行为差异,完整 支持矩阵见 2.5。wss://{host}/ete/v1/{appid}?model=audio-gg-3.8-live&secretId=...&signature=...&timeStamp=...&expired=...&nonce=...
audio-gem-3.8-live(任意大小写)仍可继续使用,服务端会自动归一为 audio-gg-3.8-live,行为与计费完全一致。新接入请使用 audio-gg-3.8-live。instructions / voice / tools / language 均在首次 session.update 时生效,后续 session.update 不生效(所有能力一致)。如需变更请重新建立连接。session.audio.output.voice):仅支持以下内置音色,大小写不敏感;不在列表内(如 alloy)时静默回退到默认音色,不中断建连:Zephyr / Puck / Charon / Kore / Fenrir / Leda / Orus / Aoede / Callirrhoe /Autonoe / Enceladus / Iapetus / Umbriel / Algieba / Despina / Erinome / Algenib /Rasalgethi / Laomedeia / Achernar / Alnilam / Schedar / Gacrux / Pulcherrima /Achird / Zubenelgenubi / Vindemiatrix / Sadachbia / Sadaltager / Sulafatsession.audio.input.transcription.language):可选,作为 ASR 语言提示,推荐 BCP-47 形式(如 zh-CN / en-US);不传时自动识别。session.tools):遵循标准 GA Function Tool schema(name / description /parameters),仅支持 type=function,其它类型被忽略。turn_detection 被忽略。error(code=upstream_closed) 断开,客户端需重新建连(上下文不会保留)。事件 | 行为 |
input_audio_buffer.speech_started / speech_stopped / committed | 不保证下发(依赖模型服务是否提供语音活动信号)。客户端请勿以此作为必需的状态驱动,推荐以 response.created / transcription.delta 作为"用户已说话 / 模型已开始回复"的信号。 |
conversation.item.input_audio_transcription.delta | ✅ 追加式增量 |
conversation.item.input_audio_transcription.completed | ✅ 由服务端合成, transcript 为本段用户话语各 delta 的拼接;在助手开始回复时下发(模型未回复时,在用户开始下一段话或本轮结束时下发)。不带 usage。 |
conversation.item.created | ❌ 不下发(含 conversation.item.create 的回执)。 |
response.created / response.done | ✅ 每轮回复各一次; response_id 由服务端生成。 |
response.output_audio_transcript.delta / .done | ✅ .done 的 transcript 为本轮各 delta 的拼接。 |
output_audio_buffer.started | ❌ 不下发。 |
output_audio_buffer.stopped | ✅ 在本轮音频结束时下发。 |
response.create 语义场景 | 行为 |
带 response.instructions | instructions 作为一条用户文本输入发给模型,模型据此回复(不是逐字朗读)。用于"主动打招呼"时请写成指令形式,如 "请用一句话向用户打招呼"。 |
不带 instructions,且之前通过 conversation.item.create 追加过 message | 触发模型基于已追加内容回复。 |
不带 instructions,其它情况 | 静默 no-op,无回执(function call 回传后模型会自动续接,无需发送)。 |
conversation.item.create(type=message)只追加上下文、不会自动触发回复,与标准 GA 一致;role=assistant 作为模型历史发言,user / system 均作为用户输入。instructions 或追加 message 后的 response.create)时,若当前有回复正在进行,该回复可能被打断并以 response.done(status=cancelled) 结束。response.output_audio.done / response.output_audio_transcript.done(如有)与 response.done.status=cancelled)。客户端收到后应清空本地播放缓冲。response.cancel / output_audio_buffer.clear:服务端立即以 status=cancelled 结束当前 response,并丢弃该轮后续的音频 / 文本 / function call;output_audio_buffer.clear 额外回 output_audio_buffer.cleared。无进行中的 response 时 response.cancel 为 no-op,无回执。usage 可能不完整,未结算部分会计入下一轮 response.done.usage。项目 | audio-gg-3.8-live |
image_url | 仅支持 Data URL: data:image/{png,jpeg,webp,heic,heif};base64,...(image/jpg 视同 image/jpeg)。也兼容 {"url": "data:..."} 对象写法。 |
HTTP(S) URL | ❌ 不支持,回 error(code=invalid_image)。 |
gif 等其它格式 | ❌ 不支持,回 error(code=invalid_image)。 |
单张大小 | 解码后 ≤ 7 MB,超过回 error(code=invalid_image);建议 ≤ 2 MB 以降低延迟。 |
detail | 忽略。 |
回执 | 不下发 conversation.item.created;成功时无回执,失败时回 error(code=invalid_image)。 |
校验失败 | 整条 item 不生效(文本也不会发送),不会静默丢弃图片只发文本。 |
{"type": "response.create"} 触发回复。图片 tokens 计入 response.done.response.usage.input_token_details.image_tokens。response.function_call_arguments.done(带 response_id / item_id /call_id / name / arguments),随后立即下发本轮 response.done。conversation.item.create(type=function_call_output) 回传结果,call_id 须与下行一致;output 推荐使用 JSON 字符串(如 "{\\"time\\":\\"09:30\\"}"),非 JSON 字符串按纯文本处理。response_id)播报结果,无需发送 response.create。input_token_details:text_tokens / audio_tokens / image_tokens / cached_tokens(适用时)。output_token_details:text_tokens / audio_tokens / reasoning_tokens(适用时,为 text_tokens 的内含子集)。cache_write_tokens。
HTTP 状态 | Reason Phrase | 触发原因 |
400 | invalid_request: ... | URL 参数缺失 / appid 非法 / model 值非法。 |
401 | invalid_timestamp | timeStamp 或 expired 已过期或格式错误。 |
401 | authentication_failed: code=<n> | CAM 签名校验失败。 |
403 | account_invalid | 账户欠费 / 冻结。 |
429 | connection_limit_exceeded: uin=... num=... max=... | 并发连接数超上限。 |
500 | authentication_failed: <err> | CAM 后端调用异常。 |
500 | check_user_status_error: <err> | 账户状态查询异常。 |
500 | limit_check_error: <err> | 并发限流查询异常。 |
error 事件下发:error.type | error.code | 说明 |
invalid_request_error | invalid_json | 消息不是合法 JSON。 |
invalid_request_error | invalid_audio | 上行音频 base64 解码或解码器解析失败。 |
invalid_request_error | unsupported_output_format | 下行 format 非 pcm / opus,或 opus 采样率不在白名单。 |
invalid_request_error | not_supported | 使用了当前会话能力下不支持的控制事件(如 conversation.item.truncate / transcription_session.update / 不带 instructions 的空 response.create)。 |
invalid_request_error | session_not_ready | 未先发 session.update 就送控制事件(response.create / conversation.item.* 等)。 |
invalid_request_error | missing_item | conversation.item.create 缺 item 字段。 |
invalid_request_error | missing_item_id | conversation.item.retrieve / delete 缺 item_id 字段。 |
server_error | pipeline_init_failed | 服务端会话初始化失败。 |
server_error | upstream_send_error | 服务端向能力后端发送数据失败。 |
server_error | upstream_error | 能力后端返回异常。 |
server_error | upstream_closed | 能力后端主动关闭。 |
session_expired | idle_timeout | 会话空闲超时(默认 30 s,可通过 timeoutSec 覆盖)。 |
session.update 完成会话初始化,服务端才回 session.updated(作为“首次可见响应”),此后才能开始送音频。这与标准 GA 规范中 session.created 先行的行为有意不同,为的是更符合“客户端主动”的语义。timeStamp 与服务器差异不超过 15 分钟,先用 date -u 校准机器时间。signature 外的所有 query 参数都要参与签名。timeoutSec / model / resId 只要出现在 URL 上就必须一并进入 canonicalQueryString。k=urlEncode(v) 用 & 拼接。content-type;host 之前必须有一个空行(\\n\\n)。Text 帧承载的 JSON 事件。音频通过 input_audio_buffer.append 事件里的 audio 字段以 base64 承载。session.updated 之后立即发:{ "type": "response.create","response": { "instructions": "你好, 我是智能助手, 请问需要什么帮助?" } }
model 都支持这种“客户端指定文本,让服务端主动说出”的用法。session.update.audio.output.format 中声明:{ "format": { "type": "opus", "rate": 48000 } }
8000 / 12000 / 16000 / 24000 / 48000。返回的 response.output_audio.delta.delta 字段是裸 Opus packet 的 base64(一次 delta 通常对应一个20ms Opus 帧),客户端需用 Opus 解码器还原为 PCM。conversation.item.truncate 报 not_supported,如何截断已生成的助手音频?not_supported,说明实际生效的 model 未提供原生的 truncate 能力。推荐替代方案:response.cancel。output_audio_buffer.clear,服务端会一并下发 output_audio_buffer.cleared,客户端本地清空播放调度即可。timeoutSec 覆盖,上限120秒。心跳发法建议:客户端在语音间歇期偶尔发送20ms的静音 PCM input_audio_buffer.append 即可保活。session.audio.output.format 使用本服务支持的格式。session.audio.output.voice 字段同时支持明文音色 ID 与加密音色 ID,服务端会自动识别并处理:model(例如把一个 model 下的专用音色传给了另一个 model)。model 可用音色集内。response.done.response.usage 与 transcription.completed.usage 分别怎么计费?conversation.item.input_audio_transcription.completed.usagetype="duration" + seconds);部分能力会携带此字段,其余情况缺省。response.done.response.usagetotal_tokens / input_tokens / output_tokens / *_token_details);能力后端未返回 usage 时该字段缺省。response.done.response.usage(每轮)与 session.closed.usage(会话累计,所有能力)字段结构对齐 Realtime GA response.usage,客户端可据此展示完整明细:input_token_details: text, audio, image, cached, cache_write└── cached_tokens_details: text, audio, imageoutput_token_details: text, audio, reasoning
reasoning_tokens 的加总关系:output_token_details.reasoning_tokens 是 output_token_details.text_tokens 的内含子集(不是与 text / audio 并列的第三项),代表本轮回答里被消耗在推理阶段的 tokens 数量。加总关系:output_tokens = output_token_details.text_tokens + output_token_details.audio_tokensreasoning_tokens ≤ output_token_details.text_tokens // 内含关系
output_tokens=1260、text_tokens=314、audio_tokens=946、reasoning_tokens=87,可验证 314 + 946 = 1260;reasoning=87 已计入 text=314。客户端做本地用量展示时,按 text / audio 两项拆分即完整覆盖 output_tokens reasoning_tokens 作观测字段展示、不重复计入总量。文档反馈