> ## 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 令牌列表

> 更新日期：2026-06-06

## 接口说明

获取当前用户创建的所有 API 令牌（Token），支持分页。

<Note>
  这组 `/api/token/*` 接口主要用于 Crazyrouter 控制台中的 API Key 管理自动化。它们需要用户 `access token` 与 `New-Api-User` 请求头，不是给普通 `sk-xxx` 模型调用流程直接使用的接口。
</Note>

## 认证方式

使用用户的 Access Token 进行认证，需要在请求头中携带：

```text theme={null}
Authorization: Bearer {access_token}
New-Api-User: {user_id}
```

## 请求参数

<ParamField query="p" type="integer" default="1">
  页码。代码兼容旧写法，但建议从 `1` 开始
</ParamField>

<ParamField query="size" type="integer" default="10">
  每页数量，最大 100
</ParamField>

## 响应格式

```json theme={null}
{
  "success": true,
  "message": "",
  "data": {
    "page": 1,
    "page_size": 10,
    "total": 1,
    "items": [
      {
        "id": 1,
        "user_id": 1,
        "key": "sk-xxxxxxxxxxxxxxxx",
        "status": 1,
        "name": "我的令牌",
        "created_time": 1706000000,
        "accessed_time": 1706100000,
        "expired_time": -1,
        "remain_quota": 500000,
        "unlimited_quota": false,
        "model_limits_enabled": true,
        "model_limits": "[\"gpt-5.5\",\"claude-opus-4-8\"]",
        "allow_ips": "203.0.113.10",
        "used_quota": 12345,
        "group": "default"
      }
    ]
  }
}
```

## 字段说明

| 字段                     | 类型     | 说明                 |
| ---------------------- | ------ | ------------------ |
| `id`                   | int    | 令牌 ID              |
| `key`                  | string | API Key（sk-xxx 格式） |
| `status`               | int    | 状态：1=启用，2=禁用       |
| `name`                 | string | 令牌名称               |
| `expired_time`         | int    | 过期时间戳，`-1` 表示永不过期  |
| `remain_quota`         | int    | 剩余额度               |
| `unlimited_quota`      | bool   | 是否无限额度             |
| `used_quota`           | int    | 已使用额度              |
| `model_limits_enabled` | bool   | 是否启用模型白名单          |
| `model_limits`         | string | 模型限制配置字符串          |
| `allow_ips`            | string | IP 白名单字符串          |
| `group`                | string | 分组                 |

## 代码示例

<CodeGroup>
  ```python Python theme={null}
  import requests

  headers = {
      "Authorization": "Bearer your_access_token",
      "New-Api-User": "1",
      "User-Agent": "Mozilla/5.0"
  }

  response = requests.get(
      "https://api.crazyrouter.com/api/token/?p=1&size=100",
      headers=headers
  )

  page = response.json()["data"]
  for token in page["items"]:
      print(f"[{token['name']}] {token['key'][:10]}... 额度: {token['remain_quota']}")
  ```

  ```bash cURL theme={null}
  curl "https://api.crazyrouter.com/api/token/?p=1&size=100" \
    -H "Authorization: Bearer your_access_token" \
    -H "New-Api-User: 1"
  ```
</CodeGroup>
