# OpenAI TTS 格式

**方法**: `POST`
**路径**: `/v1/audio/speech`

支持流式返回，可以一边读取返回，一边播放。

## 请求参数

### Header 参数

```text
Authorization
string
可选
默认值:
Bearer {{YOUR_API_KEY}}
```

### Body 参数 application/json

```text
model
enum<string>
必需
可用的 TTS 模型之一:tts-1 或 tts-1-hd
枚举值:
speech-01-hd
speech-01-turbo
speech-02-hd
speech-02-turbo
speech-2.6-hd
speech-2.6-turbo
input
string
必需
要生成音频的文本。最大长度为4096个字符。
voice
string
必需
生成音频时使用的语音。支持的语音有:alloy、echo、fable、onyx、nova 和 shimmer。
response_format
string
可选
默认为 mp3 音频的格式。支持的格式有:mp3、opus、aac 和 flac。
speed
number
可选
默认为 1 生成的音频速度。选择0.25到4.0之间的值。1.0是默认值。
示例
{
"model"
:
"gpt-4o-mini-tts"
,
"input"
:
"The quick brown fox jumped over the lazy dog."
,
"voice"
:
"alloy"
}
```

## 请求示例代码

### Shell

```bash
curl --location --request POST '/v1/audio/speech' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gpt-4o-mini-tts",
    "input": "The quick brown fox jumped over the lazy dog.",
    "voice": "alloy"
}'
```

## 返回响应

### 🟢 200 成功

**内容类型**: `application/json`

#### 响应结构

```text
object
```

#### 示例

```json
{}
```
