Mangogo 营业厅Mangogo 营业厅
首页API 参考Skills插件

POST /v1/audio/tts/generate

POST/v1/audio/tts/generate

统一 TTS:传入文本与可选参考音频,同步返回 url / b64_json;不使用 voice 字段。

文本转语音公开接口:传入文本与可选参考音频,同步返回合成结果(非异步任务)。与 POST /v1/audio/speech 不同:本接口不接受 voice,通过 reference_audio_urls 做声音模仿,响应为 JSON(url / b64_json)。

当前常见模型:seed-audio-1.0、guidai-tts。可用模型以模型列表中 audio 类型为准。

鉴权:Bearer Token

Content-Type:application/json

请求字段

字段类型必填约束说明
modelstring是须为已启用的 audio 模型未知 / 非 audio → model_not_found
textstring是≤3000 字符待合成文本或风格提示词
reference_audio_urlsstring[]否≤3;仅 http/https;空串忽略;[] 视为未传参考音频(声音模仿)。不接受 voice
formatstring否wav / mp3 / pcm / ogg_opus输出容器格式,默认 wav
sample_rateint否见下表合法集合不传则按 format 取默认
speedfloat否[0.5, 2.0]语速倍数,默认 1.0
volumefloat否[0.5, 2.0]音量倍数,默认 1.0
pitchint否[-12, 12]音调,默认 0
enable_subtitlebool否—是否开启字幕相关能力,默认 false
response_formatstring否url / b64_json / both返回形态,默认 url

sample_rate 合法集合

format允许采样率默认
wav / pcm8000, 16000, 24000, 32000, 40000, 44100, 4800040000
mp38000, 16000, 24000, 32000, 44100, 4800044100
ogg_opus4800048000

关于音色

  • 需要指定音色时,请传 reference_audio_urls(参考音频 URL)。
  • 部分模型(如 seed-audio-1.0)也可不传参考音频,按纯文本提示合成。
  • 与 POST /v1/audio/speech 的 voice 音色代码互不通用。

请求体示例

{  "model": "seed-audio-1.0",  "text": "今天是你的生日,祝你生日快乐。",  "reference_audio_urls": [    "https://cdn.example.com/ref.mp3"  ],  "format": "mp3",  "speed": 1.0,  "response_format": "url"}

请求示例(curl)

curl https://www.mangogo.ai/v1/audio/tts/generate \  -H "Authorization: Bearer sk-xxx" \  -H "Content-Type: application/json" \  -d '{    "model": "seed-audio-1.0",    "text": "今天是你的生日,祝你生日快乐。",    "reference_audio_urls": [      "https://cdn.example.com/ref.mp3"    ],    "format": "mp3",    "speed": 1.0,    "response_format": "url"  }'

成功响应

HTTP 200

字段类型说明
createdint64Unix 秒级时间戳
dataarray结果列表(通常 1 条)
data[].urlstring公网可访问音频 URL(response_format 含 url 时)
data[].b64_jsonstringBase64 音频(response_format 含 b64_json 时)
usageobject可选;计费/用量摘要
usage.quota_typeint配额类型
usage.prompt_tokensint可选
usage.completion_tokensint可选
usage.total_tokensint可选
usage.request_countint可选
usage.quotaint本次消耗配额

response_format=url

{  "created": 1795195853,  "data": [    {      "url": "https://assets.example.com/guid/users/1/creation/2026/11/xxxx.mp3"    }  ],  "usage": {    "quota_type": 0,    "prompt_tokens": 15,    "total_tokens": 15,    "quota": 304720  }}

response_format=b64_json / both

  • b64_json:data[].b64_json 有值,通常无 url
  • both:同时返回 url 与 b64_json

错误响应

业务错误为 OpenAI 风格错误体:

{  "error": {    "message": "...",    "type": "invalid_request_error",    "code": "invalid_request"  }}
场景HTTPerror.code(常见)说明
请求体非法 / 字段校验失败400invalid_request如 text 超长、format 非法、URL 非 http(s)
模型不存在 / 非 audio400model_not_foundThe model 'xxx' does not exist
鉴权失败401 / 403—Token 无效或无权限
上游合成失败502audio_generation_failed 等上游/渠道异常
结果上传失败502upload_failed生成成功但落库/CDN 上传失败