> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/cn/compute/aig/audio-edit/openai-audio-speech.md).

# OpenAI（文字转音频）

## 1. 概述

业界第一大语言模型。根据输入文本生成音频。

**模型列表：**

* `tts-1`
* `tts-1-hd`

## 2. 请求说明

* **请求方法**:`POST`
* **请求地址**:

  > `https://gateway.theturbo.ai/v1/audio/speech`

***

## 3. 请求参数

### 3.1 Header 参数

| 参数名称            | 类型     | 必填 | 说明                                         | 示例值                    |
| --------------- | ------ | -- | ------------------------------------------ | ---------------------- |
| `Content-Type`  | string | 是  | 设置请求头类型，必须为 `application/json`             | `application/json`     |
| `Authorization` | string | 是  | 身份验证所需的 API\_KEY，格式 `Bearer $YOUR_API_KEY` | `Bearer $YOUR_API_KEY` |

***

### 3.2 Body 参数 (application/json)

| 参数名称             | 类型     | 必填 | 说明                                                                                                                                                                  | 示例（默认值）   |
| ---------------- | ------ | -- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| **model**        | string | 是  | 要使用的模型 ID。详见[概述](#id-1.-gai-shu)列出的可用版本，如 `tts-1`。                                                                                                                  | `tts-1`   |
| **input**        | string | 是  | 用于生成音频的文本，最大长度为 `4096`个字符。                                                                                                                                          | `你好，我是小明` |
| **voice**        | string | 是  | 用于生成音频的语音类型。支持：`alloy` `ash` `coral` `echo` `fable` `onyx` `nova` `sage` `shimmer`（[官网预览地址](https://platform.openai.com/docs/guides/text-to-speech#voice-options)）。 | `alloy`   |
| response\_format | string | 否  | 音频的输出格式。支持：`mp3` `opus` `aac` `flac` `wav` `pcm`。                                                                                                                   | `mp3`     |
| speed            | number | 否  | 生成音频的语速。可选的范围是`0.25`到`4.0`。                                                                                                                                         | `1.0`     |

***

## 4. 请求示例

```http
POST /v1/audio/speech
Content-Type: application/json
Authorization: Bearer $YOUR_API_KEY

{
	"model": "tts-1",
	"input": "你好，我是小明",
	"voice": "alloy"
}
```

## 5. 响应示例

```audio
HTTP/1.1 200 OK
Content-Type: audio/mpeg

音频二进制文件
```
