> ## 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 快速开始指南

> 5 分钟完成第一次 API 调用

> 内容更新: 2026-06-16

## 第一步：获取 API Key

1. 访问 [Crazyrouter](https://crazyrouter.com) 注册账号
2. 登录后进入 [Token 管理](https://crazyrouter.com/console/token) 页面
3. 点击「新建令牌」创建 API Key

## 第二步：发起请求

> [!NOTE]
>
> 默认国际接入地址请优先填写 `https://api.crazyrouter.com/v1`。东亚地区优先使用 `https://cn.crazyrouter.com/v1`。如果你不确定某个客户端应该填写根域名还是 `/v1`，先参考 [API Endpoint 说明](https://docs.crazyrouter.com/api-endpoint.md)。

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

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

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.crazyrouter.com/v1"
)

response = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "你好"}]
)
print(response.choices[0].message.content)
```

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

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.crazyrouter.com/v1'
});

const response = await client.chat.completions.create({
  model: 'gpt-5.5',
  messages: [{ role: 'user', content: '你好' }]
});
console.log(response.choices[0].message.content);
```

## 第三步：查看结果

成功的响应示例：

```json theme={null}
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1677652288,
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "你好！有什么可以帮助你的吗？"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}
```

> [!NOTE]
>
> 当前快速开始页里的 `gpt-5.5` 示例已按 2026-06-06 文档基线更新。

> [!NOTE]
>
> 所有 OpenAI 兼容的客户端和框架（如 LangChain、LlamaIndex、Cursor 等）只需修改 `base_url` 和 `api_key` 即可接入。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.