Skip to main content
POST
/
api
/
token
Create Token
curl --request POST \
  --url https://api.example.com/api/token/ \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "remain_quota": 123,
  "unlimited_quota": true,
  "expired_time": 123,
  "model_limits_enabled": true,
  "model_limits": "<string>",
  "allow_ips": "<string>",
  "group": "<string>"
}
'

Overview

Create a new API token for calling AI model APIs.
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.

Authentication

This endpoint requires user-side authentication:
Authorization: Bearer your_access_token
New-Api-User: 1

Request Parameters

name
string
required
Token name for easy identification
remain_quota
integer
default:"0"
Initial quota in internal quota units. If set to 0, use it together with unlimited_quota
unlimited_quota
boolean
default:"false"
Whether the token has unlimited quota
expired_time
integer
default:"-1"
Expiration timestamp. -1 means never expires
model_limits_enabled
boolean
default:"false"
Whether to enable a model whitelist
model_limits
string
Model restriction config as a string, usually a JSON string such as ["gpt-5.4","claude-sonnet-4-6"]
allow_ips
string
IP whitelist string. You can pass a single IP or multiple IPs separated by newlines
group
string
Token group. It must be a group the current user is allowed to use

Response Format

The current implementation only returns a success state after creation:
{
  "success": true,
  "message": ""
}

Code Examples

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://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.4", "claude-sonnet-4-6"]),
        "allow_ips": "203.0.113.10"
    }
)

print(response.json())
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.