# Doubao-流式语音识别（WebSocket）

双向流式 ASR：实时将音频流转写为文本。二进制协议与请求流程与火山官方一致，详见 [官方 · 大模型流式语音识别 API](https://www.volcengine.com/docs/6561/1354869?lang=zh)。

<div class="doc-interface">
  <p><strong>URL</strong>：<code>wss://&lt;BASE&gt;/v3/sauc/bigmodel</code></p>
  <p><strong>Method</strong>：<code>GET</code>（WebSocket 升级）</p>
  <p><strong>模型</strong>：<code>Doubao-ASR-Stream</code>（可选 query <code>?model=</code> 覆盖）</p>
</div>

<div class="doc-api-spec">

## 与官方直连的差异

- **鉴权**：握手时使用本平台颁发的 **API Key**，不要使用火山控制台 AppKey。
- **上游凭证**：网关会使用 Provider 配置中的上游 `api_key` 或火山 `app_key` / `access_key` 连接。
- **数据帧**：`full client request`、`audio only request`、`full server response` 等二进制帧 **原样透传**，无需修改 payload。

## 授权

以下任选其一（值为平台 API Key）：

### `Authorization`

- **类型** `string` · **位置** `header`
- **格式** `Bearer <API_KEY>`

### `X-Api-App-Key`

- **类型** `string` · **位置** `header`
- **说明** 与 openspeech 官方头同名，但此处填 **平台 API Key**。

### `api_key`

- **类型** `string` · **位置** `query`
- **说明** 部分 WebSocket 客户端无法自定义 Header 时可用：`wss://.../v3/sauc/bigmodel?api_key=<API_KEY>`

## 协议与交互

1. 客户端发起 WebSocket 握手（带 API Key）。
2. 发送 **full client request**（gzip JSON 参数）。
3. 多次发送 **audio only request**（gzip 音频分片）；最后一包需按官方文档设置 message type specific flags。
4. 服务端返回 **full server response**（识别结果 JSON，gzip）；最后一包结果帧用于标识会话结束。

完整 header 位域、message type、压缩方式等见 [官方文档 · WebSocket 二进制协议](https://www.volcengine.com/docs/6561/1354869?lang=zh)。

## 计费

- **模型**：`Doubao-ASR-Stream`（`type=audio`）
- **维度**：`asr_duration_ms`（识别音频时长，毫秒）
- **单价**：在控制台为该模型单独配置（与极速版 `Doubao-ASR-Flash` 独立）

## 参考

- [火山引擎 · 大模型流式语音识别 API](https://www.volcengine.com/docs/6561/1354869?lang=zh)
- 录音文件极速版（HTTP）：站内 [录音文件 ASR（极速版）](/api-asr-flash-doubao)

</div>
