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

# 智能路由

## 介紹

Smart Routing 是一項智慧模型路由能力，能夠根據輸入任務的複雜程度，自動將請求分配至最合適的模型。透過將任務劃分為 **simple**（簡單）、**complex**（複雜）、**ultra**（旗艦）三個等級，Smart Routing 可以在保證輸出品質的前提下，有效降低 API 呼叫成本。其中 Ultra 為價格基準。

### 使用限制

**快取能力限制**

路由過程中，快取特性將受到影響。不同模型之間的快取機制和快取節點存在差異，切換模型時快取將被刷新，無法重複使用。

**請求體結構限制**

Smart Routing 使用 `/v1/chat/completions` 端點。當路由目標為 Claude 系列模型時，只能透過 OpenAI 相容模式運作。相容後的功能限制請參考 Anthropic 官方文件 [OpenAI SDK compatibility](https://platform.claude.com/docs/en/cli-sdks-libraries/libraries/openai-sdk)。

### 使用指南

1. 建立路由

<Frame>
  <img src="https://mintcdn.com/personal-a5418d9f/35UMqVTCuMQi8uxs/images/smart-routing-1.png?fit=max&auto=format&n=35UMqVTCuMQi8uxs&q=85&s=52b85562775173efaa75de39aee75177" alt="Smart Routing 1" width="475" height="797" data-path="images/smart-routing-1.png" />
</Frame>

2. 為路由節點建立金鑰

<Frame>
  <img src="https://mintcdn.com/personal-a5418d9f/35UMqVTCuMQi8uxs/images/smart-routing-2.png?fit=max&auto=format&n=35UMqVTCuMQi8uxs&q=85&s=8bd380bb4b1382da5a39d99bf61df627" alt="Smart Routing 2" width="2235" height="546" data-path="images/smart-routing-2.png" />
</Frame>

3. 為金鑰選擇 Default 分組

<Frame>
  <img src="https://mintcdn.com/personal-a5418d9f/35UMqVTCuMQi8uxs/images/smart-routing-3.png?fit=max&auto=format&n=35UMqVTCuMQi8uxs&q=85&s=90a1f8639c569aad34c4dd0c7e860d5c" alt="Smart Routing 3" width="1620" height="1302" data-path="images/smart-routing-3.png" />
</Frame>

4. 分別為 simple、complex、ultra 三個級別設定對應模型

<Frame>
  <img src="https://mintcdn.com/personal-a5418d9f/35UMqVTCuMQi8uxs/images/smart-routing-4.png?fit=max&auto=format&n=35UMqVTCuMQi8uxs&q=85&s=45eeff76775a4f9f8e24809e3fbe68f5" alt="Smart Routing 4" width="2234" height="1509" data-path="images/smart-routing-4.png" />
</Frame>

5. 設定並透過智慧閘道進行路由

* 通訊端點：`https://api.mixroute.ai/v1/chat/completions`
* 模型名稱：`auto`
* 金鑰：使用路由的金鑰

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