千問語音與音訊

支援 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