获取令牌列表
curl --request GET \
--url https://api.example.com/api/token/import requests
url = "https://api.example.com/api/token/"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
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 => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/token/"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/token/")
.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::Get.new(url)
response = http.request(request)
puts response.read_bodyAPI Key & 控制台管理
获取令牌列表
分页获取当前用户的 API 令牌列表
GET
/
api
/
token
/
获取令牌列表
curl --request GET \
--url https://api.example.com/api/token/import requests
url = "https://api.example.com/api/token/"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
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 => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/token/"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/token/")
.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::Get.new(url)
response = http.request(request)
puts response.read_body更新日期:2026-06-06
接口说明
获取当前用户创建的所有 API 令牌(Token),支持分页。这组
/api/token/* 接口主要用于 Crazyrouter 控制台中的 API Key 管理自动化。它们需要用户 access token 与 New-Api-User 请求头,不是给普通 sk-xxx 模型调用流程直接使用的接口。认证方式
使用用户的 Access Token 进行认证,需要在请求头中携带:Authorization: Bearer {access_token}
New-Api-User: {user_id}
请求参数
页码。代码兼容旧写法,但建议从
1 开始每页数量,最大 100
响应格式
{
"success": true,
"message": "",
"data": {
"page": 1,
"page_size": 10,
"total": 1,
"items": [
{
"id": 1,
"user_id": 1,
"key": "sk-xxxxxxxxxxxxxxxx",
"status": 1,
"name": "我的令牌",
"created_time": 1706000000,
"accessed_time": 1706100000,
"expired_time": -1,
"remain_quota": 500000,
"unlimited_quota": false,
"model_limits_enabled": true,
"model_limits": "[\"gpt-5.5\",\"claude-opus-4-8\"]",
"allow_ips": "203.0.113.10",
"used_quota": 12345,
"group": "default"
}
]
}
}
字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
id | int | 令牌 ID |
key | string | API Key(sk-xxx 格式) |
status | int | 状态:1=启用,2=禁用 |
name | string | 令牌名称 |
expired_time | int | 过期时间戳,-1 表示永不过期 |
remain_quota | int | 剩余额度 |
unlimited_quota | bool | 是否无限额度 |
used_quota | int | 已使用额度 |
model_limits_enabled | bool | 是否启用模型白名单 |
model_limits | string | 模型限制配置字符串 |
allow_ips | string | IP 白名单字符串 |
group | string | 分组 |
代码示例
import requests
headers = {
"Authorization": "Bearer your_access_token",
"New-Api-User": "1",
"User-Agent": "Mozilla/5.0"
}
response = requests.get(
"https://api.crazyrouter.com/api/token/?p=1&size=100",
headers=headers
)
page = response.json()["data"]
for token in page["items"]:
print(f"[{token['name']}] {token['key'][:10]}... 额度: {token['remain_quota']}")
curl "https://api.crazyrouter.com/api/token/?p=1&size=100" \
-H "Authorization: Bearer your_access_token" \
-H "New-Api-User: 1"
⌘I