开启会话听写流(扩展)
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/dictations● 支持请求参数
session_idstring必填path: Session id from session creation or listing.
hotwordsarray可选Words the recogniser should favour, at most 50.
返回
201
仅在 /agent/v1 提供。请求体可选:hotwords(最多 50 个词,提示识别器优先采用)。返回 201 { id, push_url, expires_at }:id 是流的 id(mst_...),push_url 是 wss 地址,expires_at 是地址不再接受新连接的时间。语音识别模型是智能体的 dictation_model,未设置时用平台默认模型。客户端连上 push_url 后先发一个文本帧 {"type":"start","format":"pcm_s16le","sample_rate":16000,"channels":1},再发二进制 PCM 帧(每帧不超过 64 KiB),最后发 {"type":"stop"};收到的文本帧有 partial、final、done(含 audio_seconds、cost_usd)和 error。每个 final 带 end_ms,表示这句话在你发送的音频里结束的位置:连接断了,把最后一个 end_ms 之后的音频发给新开的听写即可。可以提前连上:发 start 之前,流最多等 5 分钟;发 start 之后 30 秒没有帧就关闭;一条流最多 10 分钟音频。push_url 带短时授权,当作密钥对待,不要保存或写进日志。会话不存在或不可见返回 404;解析出的模型不能做流式转写返回 409 DICTATION_UNCONFIGURED;当前环境暂不能听写返回 503 DICTATION_UNAVAILABLE;hotwords 超过 50 个或字段不支持返回 400。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
请求示例
curl
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
curl https://api.deepraxis.com/agent/v1/sessions/sesn_123/dictations \
-H "Authorization: Bearer $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"hotwords":["Praxis","Ticket"]}'Python
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
import requests
opts = dict(
base_url="https://api.deepraxis.com/agent",
api_key="$PRAXIS_API_KEY",
)
# /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
resp = requests.post(
f"{opts['base_url']}/v1/sessions/sesn_123/dictations",
headers={"Authorization": f"Bearer {opts['api_key']}"},
json={"hotwords":["Praxis","Ticket"]},
)
print(resp.status_code, resp.json())TypeScript
// 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
const opts = {
baseURL: "https://api.deepraxis.com/agent",
apiKey: "$PRAXIS_API_KEY",
};
// /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
const resp = await fetch(`${opts.baseURL}/v1/sessions/sesn_123/dictations`, {
method: "POST",
headers: { Authorization: `Bearer ${opts.apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify({"hotwords":["Praxis","Ticket"]}),
});
console.log(resp.status, await resp.json());响应示例 201
{
"id": "mst_6u2fbhmkh5uwpwfx7bptw73rl6",
"push_url": "wss://realtime.deepraxis.com/v1/media-streams/mst_6u2fbhmkh5uwpwfx7bptw73rl6/push?token=REDACTED_PUSH_CAPABILITY",
"expires_at": "2026-11-27T18:06:45.747Z"
}响应
HTTP 201
The dictation stream and the address to push audio to
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | The stream's id (mst_...). |
| push_url | string | The WebSocket address to push audio to (wss://...). It carries a short-lived capability: treat it as a secret, never store or log it, and open it once. |
| expires_at | string | When the address stops accepting a new connection, RFC 3339. |