> ## 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 串流輸出。              |
