Grok Voice
集成
模型 id
xai/grok-voice
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/xai/grok-voice?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://api.doitong.com/v1";
const headers = {
"Authorization": "Bearer " + process.env.DOITONG_API_KEY,
"Content-Type": "application/json",
};
// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/xai/grok-voice?wait=20", {
method: "POST",
headers,
body: JSON.stringify({
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3"
}),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);
// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
import os
import requests
API = "https://api.doitong.com/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}
payload = {
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/xai/grok-voice", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])
# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
# 1. Connect once (Claude Code; Cursor, VS Code, Claude Desktop: https://doitong.com/zh/developers/docs/mcp)
claude mcp add --transport http doitong-models https://api.doitong.com/v1/mcp \
--header "Authorization: Bearer $DOITONG_API_KEY"
# 2. Your agent calls the "run" tool with:
{
"model_id": "xai/grok-voice",
"input": {
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3"
}
}
通过 Doitong API 调用 Grok Voice 模型(xai/grok-voice)。智能体文档:https://doitong.com/zh/developers/models/xai/grok-voice.md
POST https://api.doitong.com/v1/run/xai/grok-voice?wait=20
Authorization: Bearer $DOITONG_API_KEY
Content-Type: application/json
{
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3"
}
如果响应状态为 "queued" 或 "running",请轮询 GET https://api.doitong.com/v1/requests/REQUEST_ID?wait=20,直到状态变为 "succeeded";文件位于 outputs[].url。使用相同请求体 POST https://api.doitong.com/v1/quote/xai/grok-voice,可在运行前返回确切价格。
每次运行最高 $1.494 按实际用量计费,剩余部分退款 在此页面运行
你的新 API 密钥。 它仅在此时显示,并且已填入下方的代码和 API 密钥字段中。请妥善保密:切勿将其放入在浏览器中运行的代码。
构建请求
控件根据模型架构生成。更改控件时,代码和价格会同步更新。
POST
/run/xai/grok-voice?wait=20
报价 → $1.494
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/xai/grok-voice?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://api.doitong.com/v1";
const headers = {
"Authorization": "Bearer " + process.env.DOITONG_API_KEY,
"Content-Type": "application/json",
};
// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/xai/grok-voice?wait=20", {
method: "POST",
headers,
body: JSON.stringify({
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3"
}),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);
// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
import os
import requests
API = "https://api.doitong.com/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}
payload = {
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/xai/grok-voice", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])
# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "run",
"arguments": {
"model_id": "xai/grok-voice",
"input": {
"audio": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3"
},
"wait_seconds": 20
}
}
}
关于 Grok Voice
通过 `audio_url` 发送录音,代理会以语音回复,返回 24 kHz 单声道 WAV、时长以及可用时的转写文本。可选的 `prompt`(最多 20000 个字符)用于设置角色和上下文,`voice` 用于选择内置声音。`tools` 对象可启用网页搜索、X 搜索或远程 MCP 服务器,默认全部关闭。
参数
发送规范名称或原生名称之一,不要同时发送两者。 规范名称
名称类型
默认值允许值
描述
audio_url必填
audio
类型url · audio
用户语音的音频 URL,限制为 10 分钟和 50 MB。可提供最常见的音频格式;Grok 接收音频前,会将其转换为单声道 PCM,采样位深为 16-bit,采样率为 24 kHz。智能体会以语音回应录音内容。
prompt可选
类型string | null
≤ 20,000 个字符
可选的系统指令,用于提供对话上下文并指定 persona,以替代 Grok 的默认设置;省略后将保留默认 persona。
voice可选
类型enum
carinazaganhelixorionlunairisaltairzenithperseusheliosluxkeplerrigelcosmocelesteursa
另外 12 个
siriuslumencastornakshatlasauroralioraaraeveleorexsal选择内置 xAI 语音,以覆盖 Grok 为智能体回复设置的默认语音;不设置则保留默认语音。
tools可选
类型object
默认值{"mcp_servers":[],"web_search":{"enabled":false},"x_search":{"enabled":false}}
用于服务端的智能体工具配置。由于 ZDR,从类型化配置中排除 file_search/collections。所有工具初始均处于禁用状态;支持的选项包括远程 MCP 工具、网页工具和 X 工具。
tools.mcp_servers可选
类型object[]
模型提供商连接以执行工具的远程 MCP 服务器。
tools.mcp_servers[].allowed_tools可选
类型string[]
≥ 1 items
用于指定此服务器公开哪些工具名称的可选列表。
tools.mcp_servers[].authorization可选
类型string | null
仅发送给模型提供商的敏感授权值。
tools.mcp_servers[].enabled可选
类型boolean
默认值true
服务器包含标志;false 表示排除该服务器。
tools.mcp_servers[].headers可选
类型object | null
MCP 请求使用的敏感标头,仅发送给模型提供商。
tools.mcp_servers[].server_description可选
类型string | null
≤ 2000 characters
概述此服务器提供功能的描述。
tools.mcp_servers[].server_label必填
类型string
1 – 128 characters
模型提供商用于识别其工具并为工具名称添加前缀的服务器标签。
tools.mcp_servers[].server_url必填
类型string
≥ 1 characters
调用方为 MCP 服务器提供的 HTTP(S) 地址,Grok 通过 Streaming HTTP/SSE 传输方式远程连接该服务器。
tools.web_search可选
类型object
默认值{"allowed_domains":null,"enable_image_understanding":null,"enabled":false,"excluded_domains":null,"location":null}
由提供商管理的网页搜索,除非 enabled 为 true,否则处于禁用状态。
tools.web_search.allowed_domains可选
类型string[]
1 – 5 items
搜索结果的域名限制:最多指定五个域名,省略协议和路径。
tools.web_search.enable_image_understanding可选
类型boolean | null
允许智能体检查通过网页搜索发现的图像。
tools.web_search.enabled可选
类型boolean
默认值false
智能体的网页搜索访问权限:true 会将 web_search 添加到 session.tools 并允许网页搜索;默认值为禁用。
tools.web_search.excluded_domains可选
类型string[]
1 – 5 items
要从搜索结果中排除的域名,最多五个条目,省略协议和路径。
tools.web_search.location可选
类型object
用于按地理位置定制搜索结果的可选位置。
tools.x_search可选
类型object
默认值{"allowed_x_handles":null,"enable_image_understanding":null,"enable_video_understanding":null,"enabled":false,"excluded_x_handles":null,"from_date":null,"to_date":null}
由提供商管理的 X 搜索,除非 enabled 为 true,否则处于禁用状态。
tools.x_search.allowed_x_handles可选
类型string[]
1 – 20 items
其帖子可能出现在结果中的 X 账号句柄,最多 20 个。
tools.x_search.enable_image_understanding可选
类型boolean | null
允许智能体检查在 X 上发现的图像。
tools.x_search.enable_video_understanding可选
类型boolean | null
允许智能体检查在 X 上发现的视频。
tools.x_search.enabled可选
类型boolean
默认值false
通过搜索访问 X 帖子:true 会将 x_search 添加到 session.tools,使智能体能够搜索这些帖子;默认值为禁用。
tools.x_search.excluded_x_handles可选
类型string[]
1 – 20 items
要排除其帖子的 X 账号句柄,最多 20 个。
tools.x_search.from_date可选
类型string | null
帖子的最早日期,使用 ISO 格式 YYYY-MM-DD 表示。
tools.x_search.to_date可选
类型string | null
帖子的最晚日期,使用 ISO 格式 YYYY-MM-DD 表示。
enable_safety_checker可选
类型boolean
默认值true
调用方获得授权后,可将其设置为 false 以放宽审核。
必填
规范名称,也可接受
文件参数接受公开的 https:// URL、最大 10 MB 的 data: URI,或上传文件的 file_url。 文件
输出
GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
"id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
"object": "request",
"model": "xai/grok-voice",
"status": "succeeded",
"created_at": "2026-10-20T12:00:00Z",
"started_at": "2026-10-20T12:00:02Z",
"completed_at": "2026-10-20T12:00:09Z",
"queue_position": null,
"cost": {
"credits": 1494,
"usd": "1.494",
"charged": 1494,
"refunded": 0
},
"input": {
"audio_url": "https://content.doitong.com/audio/showcase/v3/tools/dub_es.mp3"
},
"output": {
"audio": {
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.mp3",
"content_type": "audio/mpeg",
"file_name": "0-output.mp3",
"file_size": 1843200
},
"text": "",
"duration": 5
},
"outputs": [
{
"type": "audio",
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.mp3",
"content_type": "audio/mpeg",
"file_size": 1843200,
"duration": 12,
"stored": true
}
],
"error": null,
"metrics": {
"inference_seconds": 6.8
},
"urls": {
"self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
"cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
}
}
你的文件,由你选择每个 outputs[].url 都是存储中的副本:可永久保存(按 GB-月付费),也可免费保存 7 天,由账户设置或 ?storage= 决定。
每个模型的结构相同图像、视频和音频均包含 type、url、content_type、width、height 和 duration。output 是模型自身的结果对象。
输出字段
- audio
- object {url, content_type, file_name, file_size}Grok 智能体生成的语音回复,以 24 kHz 单声道 WAV 格式传送。
- text
- string伴随智能体语音的文本:空字符串表示 Grok 未提供转录文本;否则,其中包含转录文本。
- duration
- number生成音频的时长,单位为秒。
其他 Grok Voice 变体
更多模型:音频
对于 AI 代理:此页面的 Markdown 版本位于 https://doitong.com/zh/developers/models/xai/grok-voice.md. 所有模型和指南: https://doitong.com/developers/llms.txt