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>"
}
'创建新的 API 令牌
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>"
}
'unlimited_quota 使用192.168.1.0/24。为空表示不限制{
"success": true,
"message": "",
"data": {
"id": 10,
"key": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "生产环境",
"status": 1,
"remain_quota": 100000,
"unlimited_quota": false,
"expired_time": -1,
"models": ["gpt-4o", "claude-sonnet-4-20250514"]
}
}
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,
"models": ["gpt-4o", "claude-sonnet-4-20250514", "gemini-2.5-pro"]
}
)
data = response.json()
if data["success"]:
print(f"令牌创建成功: {data['data']['key']}")
key,该值仅在创建时完整显示一次。