Agregar 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_bodyClaves API y gestión de la consola
Agregar token
Crear un nuevo token de API
POST
/
api
/
token
/
Agregar 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_bodyContenido actualizado: 2026-07-20
Descripción de la interfaz
Crea un nuevo token de API (Token), utilizado para invocar la API del modelo de IA.Este conjunto de interfaces
/api/token/* se usa principalmente para la automatización de la gestión de claves API en el panel de Crazyrouter. Necesitan access token y New-Api-User en los encabezados de solicitud del usuario, no están diseñadas para usarse directamente en el flujo de invocación habitual del modelo sk-xxx. La base de la solicitud debe ser https://crazyrouter.com; https://api.crazyrouter.com es el canal exclusivo para las APIs de los modelos, y las rutas de gestión devolverán 404 api_only_endpoint.Método de autenticación
Esta interfaz requiere autenticación por parte del usuario:Authorization: Bearer your_access_token
New-Api-User: 1
Parámetros de la solicitud
string
requerido
Nombre del token, para facilitar la identificación de su propósito
integer
predeterminado:"0"
Cuota inicial (unidad: valor interno de cuota). Si se establece en 0, debe usarse junto con
unlimited_quotaboolean
predeterminado:"false"
Definir si se configura con cuota ilimitada
integer
predeterminado:"-1"
Fecha de expiración (marca de tiempo Unix),
-1 significa que nunca expiraboolean
predeterminado:"false"
Establecer restricción de lista blanca de modelos
string
Configuración de restricción de modelos; el campo de esta interfaz es una cadena y normalmente se guarda como un JSON, por ejemplo
["gpt-5.5","claude-opus-4-8"]string
Cadena de lista blanca de IPs. Puede ser una sola IP, o varias separadas por saltos de línea
string
Grupo al que pertenece el token. Solo se puede definir grupos sobre los que el usuario actual tiene permisos de uso
Formato de respuesta
Después de crear exitosamente en esta interfaz, solo se retorna el estado de éxito:{
"success": true,
"message": ""
}
Ejemplo de código
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": "生产环境",
"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://crazyrouter.com/api/token/ \
-H "Authorization: Bearer your_access_token" \
-H "New-Api-User: 1" \
-H "Content-Type: application/json" \
-d '{
"name": "生产环境",
"remain_quota": 100000,
"expired_time": -1,
"model_limits_enabled": true,
"model_limits": "[\"gpt-5.5\"]"
}'
La interfaz de creación actual no devolverá el
key completo generado en la respuesta. Si tu proceso requiere copiar inmediatamente la clave íntegra, se recomienda crearla y guardarla por medio del panel.