本文档由 云音工坊 自动生成,如有疑问,请联系客服微信:yuntts !
| 项目 | 说明 |
|---|---|
| 请求地址 | POST /api/v1/chattts |
| 请求格式 | application/json |
| 认证方式 | 用户认证 Token(请求头携带) |
| 响应格式 | 音频二进制流 |
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
input | string | 是 | — | 要合成语音的文本内容 |
model | string | 否 | ChatTTS | 模型名称(接口自动填充,无需传入) |
prompt | string | 否 | [oral_1] | 口语化程度 0-9,数值越小越官方,越大越生活化。支持传数字(如 1)或 [oral_1] 格式 |
temperature | number | 否 | 0.2 | 采样温度,控制输出随机性,范围 0~1 |
top_P | number | 否 | 0.7 | 从概率最高的前 p% 的候选词中选取 tokens,范围 0~1 |
top_K | integer | 否 | 20 | 从概率最高的前 k 个词中选取,值越大越多样,范围 0~20 |
voice | string | 条件 | — | 预设音色,与 voice_url 二选一。可选:alloy / echo / fable / onyx / nova / shimmer |
voice_url | string | 条件 | — | .pt 格式的文件链接,用于自定义音色,与 voice 二选一 |
{
"input": "欢迎使用语音合成服务",
"voice": "nova"
}{
"input": "欢迎使用语音合成服务",
"voice_url": "https://example.com/voice.pt"
}{
"input": "欢迎使用语音合成服务"
}| 响应头 | 说明 | 示例 |
|---|---|---|
Content-Type | 音频 MIME 类型 | audio/wav |
Content-Length | 音频文件大小(字节) | 101966 |
X-Characters | 合成文本的加权字符数 | 42 |
X-Cost | 扣费金额(元) | 0.03 |
X-Task-Id | 任务唯一ID | chattts_xxxxxxxx |
{
"code": "错误码",
"message": "错误描述"
}| HTTP 状态码 | 错误码 | 说明 |
|---|---|---|
| 400 | invalid_parameters | 缺少必要参数或参数冲突 |
| 400 | json_decode_failed | JSON 解析失败 |
| 401 | unauthorized | 未登录或认证失败 |
| 403 | insufficient_balance | 余额不足 |
| 405 | method_not_allowed | 仅支持 POST 请求 |
| 500 | missing_api_key | API 密钥未配置 |
| 500 | transaction_failed | 合成失败(已退款) |
| 用户类型 | 每次调用费用 |
|---|---|
| 普通用户 | ¥0.03 |
| VIP / BOOSVIP | ¥0.02 |
说明:ChatTTS 按次计费,与合成文本长度无关。API 请求失败时自动全额退款。
curl --location 'https://www.yuntts.com/api/v1/chattts' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data '{
"input": "in pariatur laboris",
"model": "ChatTTS",
"prompt": "[oral_1]",
"temperature": 0.2,
"top_P": 0.7,
"top_K": 20,
"voice": "nova"
}'