千问语音与音频

支持 OpenAI 兼容(直返二进制音频)与阿里百炼原生(透传 JSON)双入口。官方文档

[!NOTE] 示例中的模型 ID 仅供参考,实际调用请以 模型广场 对应的真实 ID 为准。

模型与路由速查

模型能力OpenAI 兼容(二进制)百炼原生(JSON)规格计费
qwen-audio-3.1-tts-flash极速语音合成、instructionsPOST /v1/audio/speechPOST /api/v1/services/audio/tts/SpeechSynthesizer3.1 音色;mp3/wav/pcm;16000/24000/48000输入/输出 Token
qwen-audio-3.1-tts-plus高表现力语音合成、instructionsPOST /v1/audio/speechPOST /api/v1/services/audio/tts/SpeechSynthesizer同上字符(非 ASCII=2,ASCII=1)
qwen-audio-3.1-tts-next全场景音频生成(对白/音效/环境音/立体声/≤3 参考音)POST /v1/audio/speechPOST /api/v1/services/audio/tts/SpeechSynthesizer无固定音色;wav/mp3/pcm;24000/48000;1/2 声道输入/输出 Token

[!TIP] 直取音频用 POST /v1/audio/speech;取原生 JSON(request_id/output.audio/usage)或用百炼 SDK 走 /api/v1/services/audio/tts/SpeechSynthesizer。鉴权统一 Authorization: Bearer sk-your_token。


1. 语音合成 3.1 (qwen-audio-3.1-tts-flash / plus)

OpenAI 兼容 (POST /v1/audio/speech)

curl -X POST https://ai.hantangai.cn/v1/audio/speech \
  -H "Authorization: Bearer sk-your_token" \
  -H "Content-Type: application/json" -o output.mp3 \
  -d '{
    "model": "qwen-audio-3.1-tts-flash",
    "input": "你好,欢迎使用千问语音合成 3.1。",
    "voice": "longanhuan_v3.1",
    "response_format": "mp3",
    "sample_rate": 24000,
    "instructions": "温柔自然,语速适中"
  }'
  • 换 qwen-audio-3.1-tts-plus 即切高表现力版;缺省或传 OpenAI/豆包音色自动回退 longanhuan_v3.1;默认 mp3/24000。

百炼原生 (POST /api/v1/services/audio/tts/SpeechSynthesizer)

curl -X POST https://ai.hantangai.cn/api/v1/services/audio/tts/SpeechSynthesizer \
  -H "Authorization: Bearer sk-your_token" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-audio-3.1-tts-flash",
    "input": { "text": "你好,欢迎使用千问语音合成 3.1。", "voice": "longanhuan_v3.1", "format": "mp3", "sample_rate": 24000, "instructions": "温柔自然,语速适中" }
  }'
  • 透传原生 JSON(request_id、output.audio.url/data、usage);plus 优先取 usage.characters(中文等非 ASCII=2,ASCII=1)。

2. 音频生成 (qwen-audio-3.1-tts-next)

生成多人对白、旁白、立体声环境音与音效,可选 ≤3 条参考音频。

OpenAI 兼容 (POST /v1/audio/speech)

curl -X POST https://ai.hantangai.cn/v1/audio/speech \
  -H "Authorization: Bearer sk-your_token" \
  -H "Content-Type: application/json" -o scene.wav \
  -d '{
    "model": "qwen-audio-3.1-tts-next",
    "input": "雨夜咖啡馆,@音频1 温柔说道:好久不见。随后轻柔钢琴渐起。",
    "audio_urls": ["https://example.com/voice.wav"],
    "response_format": "wav",
    "sample_rate": 48000,
    "channels": 2
  }'
  • audio_urls 可选(≤3);默认 wav/48000/channels: 2(立体声,可选 1 单声道)。

百炼原生 (POST /api/v1/services/audio/tts/SpeechSynthesizer)

curl -X POST https://ai.hantangai.cn/api/v1/services/audio/tts/SpeechSynthesizer \
  -H "Authorization: Bearer sk-your_token" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-audio-3.1-tts-next",
    "input": {
      "text_prompt": "微雨街头,@voice1 沉稳问:方案确认了吗?@voice2 笑着答:已核对,明天推进。",
      "references": [{ "audio_url": "https://example.com/a.wav" }, { "audio_url": "https://example.com/b.wav" }],
      "format": "wav", "sample_rate": 48000, "channels": 2
    }
  }'
  • 网关自动将 @音频1–@音频3 转为 @voice1–@voice3;传入参考音但未写占位符时自动补齐开头引用。

3. 音色速查

仅适用 flash/plus(next 由提示词或 references 控制)。下方音色库默认展示 Qwen 3.1,支持搜索、复制与试听。

分类常用示例(可直接复制)
中文女声龙安欢 longanhuan_v3.1 · 龙安芊 longanqian_v3.1 · 龙安灵心 longanlingxin_v3.1 · 龙安风悦 longanfengyue_v3.1 · 龙安筠 longanyun_v3.1
中文男声许南川 xunanchuan_v3.1 · 龙安燃 longanran_v3.1 · 龙安洋 longanyang_v3.1
英文 / 多语种Beth beth_v3.1 · Betty betty_v3.1 · Cally cally_v3.1

5. 常见错误码与问题排查

完整 HTTP 状态码、错误体格式及分场景排查请参阅:

👉 网关常见错误码与排查

速记(详情见专页):

码含义
400参数非法 / 内容风控或版权拦截
402账户余额不足(不是 429)
429令牌 RPS/RPM 限频,或低余额在途任务过多
403令牌/IP/模型权限(余额见 402;内容拦截见 400)
200 + status: failed异步视频等长任务的业务失败(轮询时常见)

HTTP 响应码与控制台调用日志 status_code 一致,可按 log_id 追溯。

Raw Markdown (.md) · llms.txt