# Text-to-Speech (TTS) Endpoints

OpenAI-compatible text-to-speech endpoint: `POST /v1/audio/speech`.

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

### 1. Speech Synthesis
* **Path**: `/v1/audio/speech`
* **Request Method**: `POST`
* **Authentication**: `Authorization: Bearer sk-your_token`

#### Request Parameters
| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| `model` | `string` | Yes | TTS model name, e.g. `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts` (also compatible with platform-integrated vendor audio models) |
| `input` | `string` | Yes | The text to be synthesized into speech; maximum length depends on the model specification |
| `voice` | `string` | Yes | Voice identifier: standard OpenAI voices (`alloy`, `echo`, `fable`, `onyx`, `nova`, `shimmer`, `ash`, `coral`, `sage`), or the corresponding vendor voice ID for non-OpenAI models |
| `response_format` | `string` | No | Audio output format: `mp3` (default), `opus`, `aac`, `flac`, `wav`, `pcm` |
| `speed` | `number` | No | Speech speed multiplier (OpenAI standard range `0.25`–`4.0`, default `1.0`) |
| `instructions` | `string` | No | Optional natural-language voice style/tone instructions (for supported models such as `gpt-4o-mini-tts`) |

#### Calling Example
```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": "tts-1",
    "input": "Hello, welcome to the unified text-to-speech service.",
    "voice": "alloy",
    "response_format": "mp3",
    "speed": 1.0
  }'
```

> [!NOTE]
> This endpoint returns a raw binary audio stream (HTTP binary response with `Content-Type` set to `audio/mpeg` or the matching format MIME type) that can be saved directly as an audio file.

> [!TIP]
> For Doubao audio models (`doubao-seed-audio-1-5-261128`, `doubao-seed-tts-3.0`, `seed-tts-2.0`, `seed-audio-1.0`), see **[Doubao Audio & TTS](/docs/en/examples/volc-audio)**.
> For Alibaba Qwen audio models (`qwen-audio-3.1-tts-flash`, `plus`, `next`), see **[Qwen Audio & TTS](/docs/en/examples/qwen-audio)**.
