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>"
}
'import requests
url = "https://api.example.com/api/token/"
payload = {
"name": "<string>",
"remain_quota": 123,
"unlimited_quota": True,
"expired_time": 123,
"model_limits_enabled": True,
"model_limits": "<string>",
"allow_ips": "<string>",
"group": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
remain_quota: 123,
unlimited_quota: true,
expired_time: 123,
model_limits_enabled: true,
model_limits: '<string>',
allow_ips: '<string>',
group: '<string>'
})
};
fetch('https://api.example.com/api/token/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/token/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'remain_quota' => 123,
'unlimited_quota' => true,
'expired_time' => 123,
'model_limits_enabled' => true,
'model_limits' => '<string>',
'allow_ips' => '<string>',
'group' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/token/"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"remain_quota\": 123,\n \"unlimited_quota\": true,\n \"expired_time\": 123,\n \"model_limits_enabled\": true,\n \"model_limits\": \"<string>\",\n \"allow_ips\": \"<string>\",\n \"group\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/token/")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"remain_quota\": 123,\n \"unlimited_quota\": true,\n \"expired_time\": 123,\n \"model_limits_enabled\": true,\n \"model_limits\": \"<string>\",\n \"allow_ips\": \"<string>\",\n \"group\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"remain_quota\": 123,\n \"unlimited_quota\": true,\n \"expired_time\": 123,\n \"model_limits_enabled\": true,\n \"model_limits\": \"<string>\",\n \"allow_ips\": \"<string>\",\n \"group\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyAPI Key & Console Management
Create Token
Create a new API token
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>"
}
'import requests
url = "https://api.example.com/api/token/"
payload = {
"name": "<string>",
"remain_quota": 123,
"unlimited_quota": True,
"expired_time": 123,
"model_limits_enabled": True,
"model_limits": "<string>",
"allow_ips": "<string>",
"group": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
remain_quota: 123,
unlimited_quota: true,
expired_time: 123,
model_limits_enabled: true,
model_limits: '<string>',
allow_ips: '<string>',
group: '<string>'
})
};
fetch('https://api.example.com/api/token/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/token/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'remain_quota' => 123,
'unlimited_quota' => true,
'expired_time' => 123,
'model_limits_enabled' => true,
'model_limits' => '<string>',
'allow_ips' => '<string>',
'group' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/token/"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"remain_quota\": 123,\n \"unlimited_quota\": true,\n \"expired_time\": 123,\n \"model_limits_enabled\": true,\n \"model_limits\": \"<string>\",\n \"allow_ips\": \"<string>\",\n \"group\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/token/")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"remain_quota\": 123,\n \"unlimited_quota\": true,\n \"expired_time\": 123,\n \"model_limits_enabled\": true,\n \"model_limits\": \"<string>\",\n \"allow_ips\": \"<string>\",\n \"group\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"remain_quota\": 123,\n \"unlimited_quota\": true,\n \"expired_time\": 123,\n \"model_limits_enabled\": true,\n \"model_limits\": \"<string>\",\n \"allow_ips\": \"<string>\",\n \"group\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyLast updated: 2026-06-06
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
Token name for easy identification
Initial quota in internal quota units. If set to 0, use it together with
unlimited_quotaWhether the token has unlimited quota
Expiration timestamp.
-1 means never expiresWhether to enable a model whitelist
Model restriction config as a string, usually a JSON string such as
["gpt-5.5","claude-opus-4-8"]IP whitelist string. You can pass a single IP or multiple IPs separated by newlines
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://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())
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\"]"
}'
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.⌘I