Добавить токен
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-ключи и управление консолью
Добавить токен
Создать новый API токен
POST
/
api
/
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_bodyОбновление содержания: 2026-07-20
Описание интерфейса
Создаёт новый API токен (Token), который используется для обращения к API моделей искусственного интеллекта.Эта группа интерфейсов
/api/token/* предназначена главным образом для автоматизации управления API-ключами в консоли Crazyrouter. Для работы требуется наличие в заголовке запроса access token и New-Api-User пользователя и не предназначена для прямого использования в обычных сценариях вызова моделей sk-xxx. При обращении необходимо использовать базовый адрес https://crazyrouter.com; https://api.crazyrouter.com используется только как вход для доступа к моделям API, при этом при вызове управляющих путей будет возвращён 404 api_only_endpoint.Способ аутентификации
Данный интерфейс требует аутентификации пользователя:Authorization: Bearer your_access_token
New-Api-User: 1
Параметры запроса
Начальный лимит (единицы: внутреннее значение лимита). Если установлено в 0, требуется совместное использование с
unlimited_quotaВремя истечения (Unix-метка времени),
-1 означает, что срок действия не ограниченКонфигурация ограничений моделей; на данный момент это строка, обычно хранящаяся в виде JSON, например
["gpt-5.5","claude-opus-4-8"]Строка белого списка IP-адресов. Можно указать один IP или несколько, разделённых переводом строки
Группа, к которой относится токен. Можно выбрать только те группы, к которым у текущего пользователя есть доступ
Формат ответа
После успешного выполнения запроса этот интерфейс возвращает только статус успешного выполнения:{
"success": true,
"message": ""
}
Пример кода
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\"]"
}'
При создании токена данный интерфейс не возвращает полный, только что сгенерированный
key в ответе. Если вашему процессу необходимо немедленно скопировать полный ключ, создавайте и сохраняйте его через страницу консоли.