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

# 服務商代理

> 使用 ARouter API Key 直接將請求代理到任何受支援的服務商。無需管理多個服務商金鑰。

ARouter 的服務商代理讓您使用 ARouter API Key 作為驗證，將請求直接轉發到任何受支援服務商的原生 API。無需為每個服務商個別管理 API Key。

## 端點

```
POST /{provider}/{path}
GET  /{provider}/{path}
```

其中 `{provider}` 是服務商的識別碼，`{path}` 是服務商的原生 API 路徑。

## 何時使用服務商代理

| 使用情境                                     | 建議方式                                           |
| ---------------------------------------- | ---------------------------------------------- |
| 標準 LLM 聊天補全                              | 使用 `provider/model` 格式的 `/v1/chat/completions` |
| 服務商特有功能（如 Anthropic Batches、Gemini 快取內容） | `/{provider}/{path}` 代理                        |
| 原生串流格式                                   | `/{provider}/{path}` 代理                        |
| ARouter 架構中不包含的服務商特定參數                   | `/{provider}/{path}` 代理                        |

## 支援的服務商

| 服務商             | 識別碼         | 基礎 URL                                      |
| --------------- | ----------- | ------------------------------------------- |
| OpenAI          | `openai`    | `https://api.openai.com`                    |
| Anthropic       | `anthropic` | `https://api.anthropic.com`                 |
| Google Gemini   | `google`    | `https://generativelanguage.googleapis.com` |
| DeepSeek        | `deepseek`  | `https://api.deepseek.com`                  |
| xAI             | `xai`       | `https://api.x.ai`                          |
| Kimi (Moonshot) | `kimi`      | `https://api.moonshot.cn`                   |
| MiniMax         | `minimax`   | `https://api.minimax.chat`                  |
| Mistral         | `mistral`   | `https://api.mistral.ai`                    |
| Groq            | `groq`      | `https://api.groq.com`                      |
| Cohere          | `cohere`    | `https://api.cohere.com`                    |
| NVIDIA          | `nvidia`    | `https://integrate.api.nvidia.com`          |
| Dashscope（阿里巴巴） | `dashscope` | `https://dashscope.aliyuncs.com`            |

## 範例

### OpenAI — 聊天補全

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

### Anthropic — 訊息

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

### Anthropic — 批次訊息

```bash theme={null}
# 建立批次
curl https://api.arouter.ai/anthropic/v1/messages/batches \
  -X POST \
  -H "Authorization: Bearer lr_live_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "requests": [
      {
        "custom_id": "request-1",
        "params": {
          "model": "claude-sonnet-4.6",
          "max_tokens": 1024,
          "messages": [{"role": "user", "content": "Hello!"}]
        }
      }
    ]
  }'

# 檢查批次狀態
curl https://api.arouter.ai/anthropic/v1/messages/batches/msgbatch_xxx \
  -H "Authorization: Bearer lr_live_xxxx"
```

### Google Gemini — 生成內容

```bash theme={null}
curl "https://api.arouter.ai/google/v1beta/models/gemini-2.5-flash:generateContent" \
  -X POST \
  -H "Authorization: Bearer lr_live_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "Hello!"}]}
    ]
  }'
```

### Google Gemini — 列出模型

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

### DeepSeek — 聊天補全

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

## 注意事項

* **驗證**：ARouter 會自動注入服務商的 API Key。您只需使用自己的 ARouter Key。
* **原生格式**：請求和回應原樣傳遞 — ARouter 不對其進行轉換。
* **使用量追蹤**：Token 使用量仍會記錄到您的 ARouter 帳戶。
* **路徑透傳**：`/{provider}/` 之後的所有內容將原封不動地轉發給服務商。

<Tip>
  使用服務商代理存取 Anthropic 時，`anthropic-version` 請求標頭會自動注入，無需手動加入。
</Tip>
