> ## 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`

## 请求体

格式：`multipart/form-data`

**file** `file` *required*

要转录的音频文件。支持多种格式（如 mp3、mp4、mpeg、mpga、m4a、wav、webm）。

**model** `string` *required*

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

**language** `string`

音频文件的语言，以 ISO-639-1 格式编码（如 `zh`、`en`、`ja`）。

**prompt** `string`

用于指导模型风格或继续先前音频片段的可选文本提示。提示应与音频语言匹配。

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

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

**temperature** `number`

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

**timestamp\_granularities** `array`

时间戳粒度列表。可选值为 `word` 或 `segment`。仅当 response\_format 设置为 verbose\_json 时生效。

## 响应

**text** `string`

转录生成的文本。

```bash cURL theme={"dark"}
curl -X POST "https://t.ato2.nodesms.com/v1/audio/transcriptions" \
  -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")
transcript = client.audio.transcriptions.create(
    model="whisper-1",
    file=audio_file
)
print(transcript.text)
```

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

```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.