> ## 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 认证，格式：`Bearer sk-xxxxxx`

**Content-Type** `string` *required*

固定值为 `multipart/form-data`

## 请求体

**file** `file` *required*

要翻译的音频文件。格式为二进制，支持多种音频格式（如 mp3、mp4、mpeg、mpga、m4a、wav、webm）。

**model** `string` *required*

模型 ID。例如 `whisper-1`。

**prompt** `string`

用于指导模型风格或继续先前音频片段的可选文本提示。提示应为英文。

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

翻译输出格式。可选值为 `json`、`text`、`srt`、`verbose_json`、`vtt`。默认值为 `json`。

**temperature** `number`

采样温度，介于 0 和 1 之间。默认值为 0。

## 响应

**text** `string`

翻译生成的英文文本。

```bash cURL theme={"dark"}
curl -X POST "https://t.ato2.nodesms.com/v1/audio/translations" \
  -H "Authorization: Bearer $API_KEY" \
  -F file="@audio.mp3" \
  -F model="whisper-1"
```

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

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

audio_file = open("audio.mp3", "rb")
translation = client.audio.translations.create(
    model="whisper-1",
    file=audio_file
)
print(translation.text)
```

```json 200 theme={"dark"}
{
  "text": "Hello, this is a test in English."
}
```

```json 400 theme={"dark"}
{
  "error": {
    "message": "string",
    "type": "invalid_request_error",
    "param": "file",
    "code": "string"
  }
}
```

```json 429 theme={"dark"}
{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error",
    "param": null,
    "code": "rate_limit_exceeded"
  }
}
```


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