# Qwen Audio & TTS

Supports OpenAI-compatible (binary audio) and Alibaba DashScope native (JSON passthrough) endpoints. [Official Docs](https://help.aliyun.com/zh/model-studio/qwen-tts)

> [!NOTE]
> Example model IDs are for reference only; use actual IDs from the [Model Marketplace](/models).

## Model & Route Quick Reference

| Model | Capabilities | OpenAI Compatible (Binary) | DashScope Native (JSON) | Specs | Billing |
| :--- | :--- | :--- | :--- | :--- | :--- |
| `qwen-audio-3.1-tts-flash` | Fast TTS, `instructions` | `POST /v1/audio/speech` | `POST /api/v1/services/audio/tts/SpeechSynthesizer` | 3.1 voices; `mp3`/`wav`/`pcm`; `16000`/`24000`/`48000` | Input/output tokens |
| `qwen-audio-3.1-tts-plus` | Expressive TTS, `instructions` | `POST /v1/audio/speech` | `POST /api/v1/services/audio/tts/SpeechSynthesizer` | Same as above | Chars (non-ASCII=2, ASCII=1) |
| `qwen-audio-3.1-tts-next` | Full-scene audio (dialogue/SFX/ambience/stereo/≤3 ref audio) | `POST /v1/audio/speech` | `POST /api/v1/services/audio/tts/SpeechSynthesizer` | Prompt/ref driven; `wav`/`mp3`/`pcm`; `24000`/`48000`; 1/2ch | Input/output tokens |

> [!TIP]
> Use `POST /v1/audio/speech` for binary audio; use `/api/v1/services/audio/tts/SpeechSynthesizer` for native JSON (`request_id`/`output.audio`/`usage`) or DashScope SDKs. Auth: `Authorization: Bearer sk-your_token`.

---

## 1. Speech Synthesis 3.1 (`qwen-audio-3.1-tts-flash` / `plus`)

### OpenAI Compatible (`POST /v1/audio/speech`)
```bash
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": "Hello, welcome to Qwen TTS 3.1.",
    "voice": "longanhuan_v3.1",
    "response_format": "mp3",
    "sample_rate": 24000,
    "instructions": "Warm and natural, steady pace"
  }'
```
* Switch `model` to `qwen-audio-3.1-tts-plus` for higher expressiveness; missing or OpenAI/Doubao voices fall back to `longanhuan_v3.1`; defaults to `mp3`/`24000`.

### DashScope Native (`POST /api/v1/services/audio/tts/SpeechSynthesizer`)
```bash
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": "Hello, welcome to Qwen TTS 3.1.", "voice": "longanhuan_v3.1", "format": "mp3", "sample_rate": 24000, "instructions": "Warm and natural, steady pace" }
  }'
```
* Passes through native JSON (`request_id`, `output.audio.url`/`data`, `usage`); `plus` bills by `usage.characters` (non-ASCII=**2**, ASCII=**1**).

---

## 2. Audio Generation (`qwen-audio-3.1-tts-next`)

Generates multi-speaker dialogue, narration, stereo ambience, and SFX with ≤3 optional reference audio clips.

### OpenAI Compatible (`POST /v1/audio/speech`)
```bash
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": "Rainy night cafe, @voice1 says warmly: Long time no see. Soft jazz piano fades in.",
    "audio_urls": ["https://example.com/voice.wav"],
    "response_format": "wav",
    "sample_rate": 48000,
    "channels": 2
  }'
```
* `audio_urls` optional (≤3); defaults to `wav`/`48000`/`channels: 2` (stereo, or `1` mono).

### DashScope Native (`POST /api/v1/services/audio/tts/SpeechSynthesizer`)
```bash
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": "Rainy street, @voice1 asks calmly: Plan confirmed? @voice2 smiles: Checked, launching tomorrow.",
      "references": [{ "audio_url": "https://example.com/a.wav" }, { "audio_url": "https://example.com/b.wav" }],
      "format": "wav", "sample_rate": 48000, "channels": 2
    }
  }'
```
* Auto-converts `@音频1`–`@音频3` to `@voice1`–`@voice3`, and prepends missing `@voiceN` tags when reference audio is supplied without mentions.

---

## 3. Voice Quick Reference

For `flash`/`plus` only (`next` is guided by prompts or `references`). The catalog below defaults to **Qwen 3.1** with search, copy, and preview.

| Category | Popular Voices (Click to Copy) |
| :--- | :--- |
| **Chinese Female** | Longanhuan `longanhuan_v3.1` · Longanqian `longanqian_v3.1` · Longanlingxin `longanlingxin_v3.1` · Longanfengyue `longanfengyue_v3.1` · Longanyun `longanyun_v3.1` |
| **Chinese Male** | Xunanchuan `xunanchuan_v3.1` · Longanran `longanran_v3.1` · Longanyang `longanyang_v3.1` |
| **English / Multilingual** | Beth `beth_v3.1` · Betty `betty_v3.1` · Cally `cally_v3.1` |



### 5. Common Error Codes & Troubleshooting

For full HTTP codes, error body formats, and troubleshooting guides, see:

👉 **[Gateway Error Codes & Troubleshooting](/docs/en/errors/error-codes)**

**Quick reference**:

| Code | Meaning |
| :---: | :--- |
| **400** | Invalid parameters / content moderation or copyright block |
| **402** | Insufficient account balance (**not** 429) |
| **429** | RPS/RPM limits or in-flight task cap (low balance) |
| **403** | Token / IP / model permission (balance → 402; content filter → 400) |
| **200 + `status: failed`** | Async video/long-task business failure on poll |

HTTP status matches call log `status_code` for traceability by `log_id`.
