XRToken API 文档

文字转语音(TTS)

API 配置
保存后下方「Try It」面板会自动携带此 API Key 发送真实请求。
Base: api.xrtoken.net

将文字转换为语音音频。计费方式:按字符数计费。 响应为音频二进制流,Content-Type 通常为 audio/mpeg

平台通过 model 字段自动选择最优传输协议:

  • HTTP Chunkedseed-tts-2.0):兼容性最好,适合大多数场景
  • WebSocket 单向流式seed-tts-2.0-ws):原始二进制音频,延迟更低
  • WebSocket 双向流式seed-tts-2.0-bi):完整会话管理,自动分句,长文本语音效果最佳
POST
/v1/audio/speech

Authorization

BearerAuth
AuthorizationBearer <token>

API 密钥认证(OpenAI 格式)。在 Authorization 请求头中传入:

Authorization: Bearer tr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X post "https://api.xrtoken.net/v1/audio/speech" \  -H "Content-Type: application/json" \  -d '{    "model": "volcengine/seed-tts-2.0",    "input": "你好,欢迎使用 XRToken。"  }'
"string"
{
  "error": "model field is required",
  "type": "invalid_request_error"
}
{
  "error": "invalid or missing API key",
  "type": "auth_error"
}
{
  "error": "insufficient balance -- please top up or upgrade your plan",
  "type": "billing_error"
}
{
  "error": "rate limit exceeded",
  "type": "rate_limit_error"
}
{
  "error": "upstream provider error",
  "type": "server_error"
}