创建 API 密钥
curl --request POST \
--url https://zero.cat/api/token/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "my-key",
"remain_quota": 500000,
"unlimited_quota": false,
"expired_time": -1,
"model_limits_enabled": false,
"model_limits": "",
"allow_ips": "",
"group": "",
"cross_group_retry": false,
"auto_groups": [
"<string>"
],
"allow_user_quota_query": true
}
'import requests
url = "https://zero.cat/api/token/"
payload = {
"name": "my-key",
"remain_quota": 500000,
"unlimited_quota": False,
"expired_time": -1,
"model_limits_enabled": False,
"model_limits": "",
"allow_ips": "",
"group": "",
"cross_group_retry": False,
"auto_groups": ["<string>"],
"allow_user_quota_query": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'my-key',
remain_quota: 500000,
unlimited_quota: false,
expired_time: -1,
model_limits_enabled: false,
model_limits: '',
allow_ips: '',
group: '',
cross_group_retry: false,
auto_groups: ['<string>'],
allow_user_quota_query: true
})
};
fetch('https://zero.cat/api/token/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"success": true,
"message": ""
}API 密钥管理
创建 API 密钥
需要个人访问令牌,作用域:api_key:write(API 密钥 → 编辑)。
创建成功只返回 success,不返回密钥。请随后用 获取 API 密钥列表 找到新密钥的 ID,再调用 获取完整 API 密钥。
POST
/
api
/
token
/
创建 API 密钥
curl --request POST \
--url https://zero.cat/api/token/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "my-key",
"remain_quota": 500000,
"unlimited_quota": false,
"expired_time": -1,
"model_limits_enabled": false,
"model_limits": "",
"allow_ips": "",
"group": "",
"cross_group_retry": false,
"auto_groups": [
"<string>"
],
"allow_user_quota_query": true
}
'import requests
url = "https://zero.cat/api/token/"
payload = {
"name": "my-key",
"remain_quota": 500000,
"unlimited_quota": False,
"expired_time": -1,
"model_limits_enabled": False,
"model_limits": "",
"allow_ips": "",
"group": "",
"cross_group_retry": False,
"auto_groups": ["<string>"],
"allow_user_quota_query": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'my-key',
remain_quota: 500000,
unlimited_quota: false,
expired_time: -1,
model_limits_enabled: false,
model_limits: '',
allow_ips: '',
group: '',
cross_group_retry: false,
auto_groups: ['<string>'],
allow_user_quota_query: true
})
};
fetch('https://zero.cat/api/token/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"success": true,
"message": ""
}授权
个人访问令牌(nap_ 开头),在控制台「安全与访问 → 访问令牌」中创建,不是 sk- 开头的 API 密钥。
请求体
application/json
密钥名称,最多 50 个字符
示例:
"my-key"
额度(内部额度单位)。unlimited_quota 为 true 时忽略
示例:
500000
是否无限额度
示例:
false
过期时间(Unix 秒),-1 表示永不过期
示例:
-1
是否启用模型限制
示例:
false
允许调用的模型,逗号分隔;启用模型限制时生效
示例:
""
IP 白名单,每行一个;为空表示不限制
示例:
""
密钥分组;为空表示使用账户分组
示例:
""
跨分组重试,仅 group 为 auto 时有效
示例:
false
group 为 auto 时依次尝试的分组
是否允许用这个密钥查询账户余额,新建时默认开启
示例:
true

