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

# 模型

> 透過 Models API 查詢可用模型、比較能力並瀏覽模型元資料。

ARouter 透過單一統一 API 提供來自頂級供應商的數百個模型。您可以在 [ARouter 網站](https://arouter.ai/models) 上瀏覽模型，也可以直接使用 API。

## 查詢參數

Models API 支援透過查詢參數過濾結果。

### `output_modalities`

依輸出能力過濾模型。接受以逗號分隔的模態列表，或使用 `"all"` 包含所有模型。

| 值            | 說明            |
| ------------ | ------------- |
| `text`       | 產生文字輸出的模型（預設） |
| `image`      | 產生圖像的模型       |
| `audio`      | 產生音訊輸出的模型     |
| `embeddings` | 嵌入模型          |
| `all`        | 包含所有模型，跳過模態過濾 |

```bash theme={null}
# 預設 — 僅文字模型
curl "https://api.arouter.ai/v1/models" \
  -H "Authorization: Bearer lr_live_xxxx"

# 僅圖像生成模型
curl "https://api.arouter.ai/v1/models?output_modalities=image" \
  -H "Authorization: Bearer lr_live_xxxx"

# 文字和圖像模型
curl "https://api.arouter.ai/v1/models?output_modalities=text,image" \
  -H "Authorization: Bearer lr_live_xxxx"

# 所有模型（不限模態）
curl "https://api.arouter.ai/v1/models?output_modalities=all" \
  -H "Authorization: Bearer lr_live_xxxx"
```

### `supported_parameters`

依支援的 API 參數過濾模型。例如，尋找支援工具呼叫的模型：

```bash theme={null}
curl "https://api.arouter.ai/v1/models?supported_parameters=tools" \
  -H "Authorization: Bearer lr_live_xxxx"
```

## 列出模型

```
GET /v1/models
```

傳回您的 API key 可用的完整模型列表。

```bash theme={null}
curl https://api.arouter.ai/v1/models \
  -H "Authorization: Bearer lr_live_xxxx"
```

### 回應格式

```json theme={null}
{
  "data": [
    {
      "id": "openai/gpt-5.4",
      "canonical_slug": "openai/gpt-5.4",
      "name": "GPT-5.4",
      "created": 1748000000,
      "description": "OpenAI's flagship multimodal model with state-of-the-art performance.",
      "context_length": 128000,
      "architecture": {
        "input_modalities": ["text", "image"],
        "output_modalities": ["text"],
        "tokenizer": "cl100k_base",
        "instruct_type": "chatml"
      },
      "pricing": {
        "prompt": "0.000005",
        "completion": "0.000015",
        "request": "0",
        "image": "0.00765",
        "web_search": "0",
        "internal_reasoning": "0",
        "input_cache_read": "0.0000025",
        "input_cache_write": "0.000005"
      },
      "top_provider": {
        "context_length": 128000,
        "max_completion_tokens": 16384,
        "is_moderated": true
      },
      "supported_parameters": [
        "tools",
        "tool_choice",
        "max_tokens",
        "temperature",
        "top_p",
        "structured_outputs",
        "response_format",
        "stop",
        "frequency_penalty",
        "presence_penalty",
        "seed"
      ],
      "per_request_limits": null,
      "default_parameters": null,
      "expiration_date": null
    }
  ]
}
```

## 模型物件結構

`data` 陣列中每個模型包含以下欄位：

| 欄位                     | 類型               | 說明                                     |
| ---------------------- | ---------------- | -------------------------------------- |
| `id`                   | `string`         | API 請求中使用的唯一模型識別碼，如 `"openai/gpt-5.4"` |
| `canonical_slug`       | `string`         | 模型的永久固定識別碼，永不更改                        |
| `name`                 | `string`         | 人類可讀的顯示名稱                              |
| `created`              | `number`         | 模型被新增至 ARouter 的 Unix 時間戳記             |
| `description`          | `string`         | 模型能力的詳細描述                              |
| `context_length`       | `number`         | 最大上下文視窗大小（以 Token 為單位）                 |
| `architecture`         | `Architecture`   | 技術能力物件                                 |
| `pricing`              | `Pricing`        | 使用該模型的費用結構（美元/Token）                   |
| `top_provider`         | `TopProvider`    | 主要供應商的設定詳情                             |
| `per_request_limits`   | `object \| null` | 速率限制資訊（無限制時為 `null`）                   |
| `supported_parameters` | `string[]`       | 支援的 API 參數陣列                           |
| `default_parameters`   | `object \| null` | 預設參數值（無預設值時為 `null`）                   |
| `expiration_date`      | `string \| null` | 棄用日期（未棄用時為 `null`）                     |

### Architecture 物件

```typescript theme={null}
{
  "input_modalities": string[],  // 如 ["text", "image"]
  "output_modalities": string[], // 如 ["text"]
  "tokenizer": string,           // 如 "cl100k_base"
  "instruct_type": string | null // 如 "chatml"，不適用時為 null
}
```

### Pricing 物件

所有定價值均為**美元/Token**。值為 `"0"` 表示該功能免費。

```typescript theme={null}
{
  "prompt": string,              // 每個輸入 Token 的費用
  "completion": string,          // 每個輸出 Token 的費用
  "request": string,             // 每次 API 請求的固定費用
  "image": string,               // 每張圖像輸入的費用
  "web_search": string,          // 每次網路搜尋操作的費用
  "internal_reasoning": string,  // 內部推理 Token 的費用
  "input_cache_read": string,    // 每個快取輸入 Token 讀取的費用
  "input_cache_write": string    // 每個快取輸入 Token 寫入的費用
}
```

### Top Provider 物件

```typescript theme={null}
{
  "context_length": number,         // 供應商特定的上下文限制
  "max_completion_tokens": number,  // 回應中的最大 Token 數
  "is_moderated": boolean           // 是否啟用內容審核
}
```

### 支援的參數

`supported_parameters` 陣列列出了模型支援的 OpenAI 相容參數：

| 參數                   | 說明          |
| -------------------- | ----------- |
| `tools`              | 函式呼叫能力      |
| `tool_choice`        | 工具選擇控制      |
| `max_tokens`         | 回應長度限制      |
| `temperature`        | 隨機性控制       |
| `top_p`              | 核採樣         |
| `reasoning`          | 內部推理模式      |
| `include_reasoning`  | 在回應中包含推理過程  |
| `structured_outputs` | JSON 結構強制執行 |
| `response_format`    | 輸出格式規範      |
| `stop`               | 自訂停止序列      |
| `frequency_penalty`  | 重複減少        |
| `presence_penalty`   | 話題多樣性       |
| `seed`               | 確定性輸出       |

## 使用模型

直接將 `id` 用作請求中的 `model` 欄位：

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

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

    # List available models
    models = client.models.list()
    for model in models.data:
        print(model.id)

    # Use a specific model
    response = client.chat.completions.create(
        model="anthropic/claude-sonnet-4.6",
        messages=[{"role": "user", "content": "Hello!"}],
    )
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    import OpenAI from "openai";

    const client = new OpenAI({
      baseURL: "https://api.arouter.ai/v1",
      apiKey: "lr_live_xxxx",
    });

    // List available models
    const models = await client.models.list();
    for (const model of models.data) {
      console.log(model.id);
    }

    // Use a specific model
    const response = await client.chat.completions.create({
      model: "anthropic/claude-sonnet-4.6",
      messages: [{ role: "user", content: "Hello!" }],
    });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl https://api.arouter.ai/v1/models \
      -H "Authorization: Bearer lr_live_xxxx"
    ```
  </Tab>
</Tabs>

## 依支援參數過濾

尋找支援工具呼叫的模型：

```bash theme={null}
curl "https://api.arouter.ai/v1/models?supported_parameters=tools" \
  -H "Authorization: Bearer lr_live_xxxx"
```

尋找支援結構化輸出的模型：

```bash theme={null}
curl "https://api.arouter.ai/v1/models?supported_parameters=structured_outputs" \
  -H "Authorization: Bearer lr_live_xxxx"
```

## 自動路由

除特定模型 ID 外，ARouter 還支援自動模型選擇：

| 模型       | 說明                      |
| -------- | ----------------------- |
| `"auto"` | ARouter 自動為您的請求選擇最佳可用模型 |

```bash theme={null}
curl https://api.arouter.ai/v1/chat/completions \
  -H "Authorization: Bearer lr_live_xxxx" \
  -H "Content-Type: application/json" \
  -d '{"model": "auto", "messages": [{"role": "user", "content": "Hello!"}]}'
```

回應的 `model` 欄位始終顯示實際使用的模型。詳情請參閱[模型路由](/zh-Hant/model-routing#auto-routing)。

## 模型變體

您可以在任意模型 ID 後附加後綴以影響路由行為：

| 後綴          | 效果                 |
| ----------- | ------------------ |
| `:nitro`    | 路由到最高吞吐量實例 — 速度最佳化 |
| `:floor`    | 路由到最低成本實例 — 價格最佳化  |
| `:free`     | 路由到免費層實例（有速率限制）    |
| `:thinking` | 啟用擴展推理 / 思維鏈模式     |

```json theme={null}
{"model": "openai/gpt-5.4:nitro"}   // 最快
{"model": "openai/gpt-5.4:floor"}   // 最便宜
{"model": "deepseek/deepseek-r1:thinking"} // 推理模式
```

完整參考請參閱[模型變體](/zh-Hant/guides/features/model-variants)。

## Token 化

不同模型對文字的 Token 化方式不同。某些模型（GPT、Claude、Llama）將文字分割為多字元塊；其他模型按字元 Token 化（PaLM）。這意味著即使輸入輸出完全相同，不同模型的 Token 數量——以及費用——也會有所不同。

費用按所用模型的 Token 化器計算。使用每個回應中的 `usage` 欄位取得精確的 Token 數量：

```json theme={null}
{
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 128,
    "total_tokens": 170
  }
}
```

## 注意事項

* 模型列表依您帳戶啟用的供應商過濾。若供應商未啟用，其模型將不會顯示。
* 新模型在供應商發布時自動新增。
* 直接在聊天補全請求的 `model` 欄位中使用此列表中的模型 ID。

可用供應商及其旗艦模型的精選列表請參閱[供應商](/zh-Hant/providers)。
