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