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

# Create Token

> Create a new API token

> Last updated: 2026-06-06

## Overview

Create a new API token for calling AI model APIs.

<Note>
  The `/api/token/*` endpoints are mainly for Crazyrouter dashboard automation around API key management. They require a user `access token` plus the `New-Api-User` header, and are not the normal interface for `sk-xxx` model calls.
</Note>

## Authentication

This endpoint requires user-side authentication:

```text theme={null}
Authorization: Bearer your_access_token
New-Api-User: 1
```

## Request Parameters

<ParamField body="name" type="string" required>
  Token name for easy identification
</ParamField>

<ParamField body="remain_quota" type="integer" default="0">
  Initial quota in internal quota units. If set to 0, use it together with `unlimited_quota`
</ParamField>

<ParamField body="unlimited_quota" type="boolean" default="false">
  Whether the token has unlimited quota
</ParamField>

<ParamField body="expired_time" type="integer" default="-1">
  Expiration timestamp. `-1` means never expires
</ParamField>

<ParamField body="model_limits_enabled" type="boolean" default="false">
  Whether to enable a model whitelist
</ParamField>

<ParamField body="model_limits" type="string">
  Model restriction config as a string, usually a JSON string such as `["gpt-5.5","claude-opus-4-8"]`
</ParamField>

<ParamField body="allow_ips" type="string">
  IP whitelist string. You can pass a single IP or multiple IPs separated by newlines
</ParamField>

<ParamField body="group" type="string">
  Token group. It must be a group the current user is allowed to use
</ParamField>

## Response Format

The current implementation only returns a success state after creation:

```json theme={null}
{
  "success": true,
  "message": ""
}
```

## Code Examples

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

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

  response = requests.post(
      "https://api.crazyrouter.com/api/token/",
      headers=headers,
      json={
          "name": "Production",
          "remain_quota": 100000,
          "unlimited_quota": False,
          "expired_time": -1,
          "model_limits_enabled": True,
          "model_limits": json.dumps(["gpt-5.5", "claude-opus-4-8"]),
          "allow_ips": "203.0.113.10"
      }
  )

  print(response.json())
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.crazyrouter.com/api/token/ \
    -H "Authorization: Bearer your_access_token" \
    -H "New-Api-User: 1" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Production",
      "remain_quota": 100000,
      "expired_time": -1,
      "model_limits_enabled": true,
      "model_limits": "[\"gpt-5.5\"]"
    }'
  ```
</CodeGroup>

<Warning>
  The current create endpoint does not return the full generated `key` in the response. If your workflow requires copying the full token immediately, prefer creating it from the console UI and saving it there.
</Warning>
