> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refillapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to speech

> POST /v1/audio/speech with Qwen TTS — OpenAI-compatible, returns an audio file.

Qwen TTS turns text into natural speech, with a choice of voices, speed, and a one-sentence instruction for tone and emotion. The endpoint is compatible with OpenAI's speech API and returns the audio file directly.

* Model ID: `qwen-audio-3.1-tts-plus`
* Endpoint: `POST https://refillapi.com/v1/audio/speech` (synchronous)
* [Price](https://refillapi.com/pricing/qwen-audio-3.1-tts-plus)

## Request

**model** `string` *required*

`qwen-audio-3.1-tts-plus`

**input** `string` *required*

Text to speak. Up to 20,000 billable characters per request.

**voice** `string`

Voice ID from the table below (case-sensitive). Omitted, or an OpenAI voice name such as `alloy`, uses the default `longanhuan_v3.1`.

**response\_format** `string` (default: mp3)

`mp3`, `wav`, `pcm` or `opus`.

**speed** `number` (default: 1)

0.5–2.

**instructions** `string`

Tone, emotion or accent in plain words, e.g. "cheerful and energetic".

**volume** `number` (default: 50)

0–100.

**pitch** `number` (default: 1)

0.5–2.

**sample\_rate** `integer`

8000, 12000, 16000, 22050, 24000, 44100 or 48000.

**language** `string`

Language hint, e.g. `en`, `zh`, `ja`.

## Voices

| `voice` | Gender |
| - | - |
| `longanhuan_v3.1` (default) | Female |
| `longanlingxin_v3.1` | Female |
| `longanfengyue_v3.1` | Female |
| `xunanchuan_v3.1` | Male |

Other voice IDs return 400 with the list of valid voices, and are not billed.

## Example

```bash curl theme={null}
curl https://refillapi.com/v1/audio/speech \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-audio-3.1-tts-plus",
    "input": "Welcome to RefillAPI. The weather is lovely today.",
    "voice": "longanhuan_v3.1",
    "language": "en"
  }' \
  --output speech.mp3
```

```python Python theme={null}
from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://refillapi.com/v1")
response = client.audio.speech.create(
    model="qwen-audio-3.1-tts-plus",
    voice="longanhuan_v3.1",
    input="Welcome to RefillAPI.",
)
response.write_to_file("speech.mp3")
```

## Billing

Per character synthesized, priced per 10,000 characters. Latin letters, digits, punctuation and spaces count as 1; each Chinese character, Japanese kana or Korean character counts as 2. Failed requests are not billed.

Streaming (`stream_format: "sse"`) is not supported; the audio is returned in one piece.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.