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

# 认证方式

> 如何获取和使用 API Key

> 更新日期：2026-06-16

## Bearer Token 认证

所有 API 请求需要在 Header 中携带 API Key：

```
Authorization: Bearer YOUR_API_KEY
```

## 获取 API Key

1. 登录 [Crazyrouter](https://crazyrouter.com)
2. 登录后进入 [Token 管理](https://crazyrouter.com/console/token) 页面
3. 点击「新建令牌」
4. 设置令牌名称、额度限制、可用模型等
5. 复制生成的 `sk-` 开头的密钥

<Warning>
  API Key 仅在创建时显示一次，请妥善保存。如果丢失，需要重新创建。
</Warning>

## 使用示例

<Note>
  OpenAI 兼容接入默认国际地址使用 `https://api.crazyrouter.com/v1`。东亚地区优先使用 `https://cn.crazyrouter.com/v1`。如果你要给 Claude Code、Hermes、OpenClaw 或其他工具配置地址，先参考 [API Endpoint 说明](https://docs.crazyrouter.com/en/api-endpoint)。
</Note>

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.crazyrouter.com/v1/chat/completions \
    -H "Authorization: Bearer sk-xxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{"model": "gpt-5.5", "messages": [{"role": "user", "content": "Hi"}]}'
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="sk-xxxxxxxx",
      base_url="https://api.crazyrouter.com/v1"
  )
  ```

  ```javascript Node.js theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: 'sk-xxxxxxxx',
    baseURL: 'https://api.crazyrouter.com/v1'
  });
  ```
</CodeGroup>

## Token 权限控制

创建 Token 时可以设置：

* **名称**：便于识别用途
* **额度限制**：设置最大可用额度
* **过期时间**：设置有效期
* **可用模型**：限制可调用的模型范围
* **IP 白名单**：限制调用来源 IP
