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

# 音频合成

> 将文本转换为音频

## 请求头

**Authorization** `string` *required*

使用 Bearer Token 认证。格式：`Authorization: Bearer sk-xxxxxx`

## 请求体

格式：`application/json`

**model** `string` *required*

模型 ID

**input** `string` *required*

要转换的文本，长度不超过 4096

**voice** `string` *required*

语音音色，可选值：`alloy`、`echo`、`fable`、`onyx`、`nova`、`shimmer`

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

音频输出格式，可选值：`mp3`、`opus`、`aac`、`flac`、`wav`、`pcm`

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

语速，取值范围 `0.25` 到 `4`

## 响应

### 200 成功生成音频

格式：`audio/mpeg`

**response** `file`

音频文件

格式：`binary`

```bash cURL theme={"dark"}
curl -X POST "https://t.ato2.nodesms.com/v1/audio/speech" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "The quick brown fox jumped over the lazy dog.",
    "voice": "alloy"
  }' \
  --output speech.mp3
```

```python Python theme={"dark"}
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxx",
    base_url="https://t.ato2.nodesms.com/v1"
)

response = client.audio.speech.create(
    model="tts-1",
    voice="alloy",
    input="The quick brown fox jumped over the lazy dog."
)
response.stream_to_file("speech.mp3")
```

```text 200 theme={"dark"}
（音频二进制数据，Content-Type: audio/mpeg）
```


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