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,
  "models": [
    "<string>"
  ],
  "subnet": "<string>"
}
'

Overview

Create a new API token for calling AI model APIs.

Request Parameters

name
string
required
Token name for easy identification
remain_quota
integer
default:"0"
Initial quota (internal quota units). When set to 0, use with unlimited_quota
unlimited_quota
boolean
default:"false"
Whether to set unlimited quota
expired_time
integer
default:"-1"
Expiration time (Unix timestamp), -1 means never expires
models
string[]
List of allowed models. Empty means all models are allowed
subnet
string
IP whitelist in CIDR format, e.g. 192.168.1.0/24. Empty means no restriction

Response Format

{
  "success": true,
  "message": "",
  "data": {
    "id": 10,
    "key": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "name": "Production",
    "status": 1,
    "remain_quota": 100000,
    "unlimited_quota": false,
    "expired_time": -1,
    "models": ["gpt-4o", "claude-sonnet-4-20250514"]
  }
}

Code Examples

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,
        "models": ["gpt-4o", "claude-sonnet-4-20250514", "gemini-2.5-pro"]
    }
)

data = response.json()
if data["success"]:
    print(f"Token created: {data['data']['key']}")
Save the returned key securely after creation. The full key is only displayed once at creation time.