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

# GPT Audio

> GPT Audio：支持语音输入与输出的音频对话模型。包含 MixRoute 调用示例与参数。

GPT Audio 是 OpenAI 推出的支持语音输入与输出的音频对话模型。

可使用下方端点通过 MixRoute 调用 `gpt-audio`。

## 核心能力

* 音频输入与输出 - 在 Chat Completions 对话中使用语音
* 音色选择 - 配置生成音频使用的音色
* 文本转录 - 在生成音频的同时获取文本
* OpenAI 兼容 - 使用 Chat Completions 请求格式

## 快速示例

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.mixroute.ai/v1/chat/completions" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "model": "gpt-audio",
      "modalities": [
        "text",
        "audio"
      ],
      "audio": {
        "voice": "alloy",
        "format": "wav"
      },
      "messages": [
        {
          "role": "user",
          "content": "Give a short spoken welcome to MixRoute."
        }
      ],
      "max_completion_tokens": 256
    }'
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import base64
    from pathlib import Path
    from openai import OpenAI

    client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.mixroute.ai/v1")

    response = client.chat.completions.create(
        model="gpt-audio",
        modalities=["text", "audio"],
        audio={"voice": "alloy", "format": "wav"},
        messages=[{"role": "user", "content": "Give a short spoken welcome to MixRoute."}],
        max_completion_tokens=256,
    )

    audio = response.choices[0].message.audio
    Path("reply.wav").write_bytes(base64.b64decode(audio.data))
    print(audio.transcript)
    ```
  </Tab>
</Tabs>

## 参数

| 参数 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `model` | string | 是 | 固定为 `gpt-audio`。 |
| `messages` | array | 是 | 对话消息，content 可包含文本或 input\_audio 内容片段。 |
| `modalities` | array | 是 | 包含 audio 以请求生成语音。 |
| `audio` | object | 是 | 输出音色与音频格式。 |
| `max_completion_tokens` | integer | 否 | 最大生成 token 数。 |
| `stream` | boolean | 否 | 启用 Chat Completions 流式输出。 |


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