API Key 精细化权限控制
简介
2026-03-20 新增 API Key 精细化权限控制功能,支持按额度、按模型、按IP白名单维度进行权限控制。
功能说明
额度控制
API Key 支持设置 每日 或 每月 费用额度上限,超过上限后将无法继续调用API。额度可以在创建/更新 API Key时设置。
操作步骤如下
登录控制台,进入API Key管理页面
点击"创建API Key"或"编辑API Key"
在"额度控制"区域,填写"每日"或"每月"额度上限
点击"创建"按钮或"保存"按钮
调用示例
curl https://airouter.xincache.cn/v1/responses\
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5.4",
"input": "Hello! Who are you?"
}'
{"error":{"message":"Access forbidden: api key quota exceeded, key_id=uminferapikey-1j3gwjgyhkwc, daily_limit_amount=100 , monthly_limit_amount=1000","type":"permission_error","param":"c2ad1049-66a6-4640-b2b5-1711dc401092","code":"forbidden"}}
模型控制
API Key 支持设置可调用的模型列表,仅可调用列表中的模型。模型可以在创建/更新 API Key时设置。
调用示例
curl https://airouter.xincache.cn/v1/responses\
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5.4",
"input": "Hello! Who are you?"
}'
{"error":{"message":"No permission to use the model: apikey [uminferapikey-1j3gwjgyhkwc] not support model [gpt-5.4]","type":"invalid_request_error","param":"6d7248f8-ebaa-437e-bfc2-d79e7c54004c","code":"model_error"}}
IP白名单控制
API Key 支持设置可调用的IP白名单,未设置时可从任意IP使用该API Key调用API,设置后仅可从IP白名单中的IP调用API。IP白名单可以在创建/更新 API Key时设置。
调用示例
curl https://airouter.xincache.cn/v1/responses\
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5.4",
"input": "Hello! Who are you?"
}'
{"error":{"message":"Access forbidden: api key ip not in whitelist, key_id=uminferapikey-1j3gwjgyhkwc, ip=127.0.0.1","type":"permission_error","param":"c2ad1049-66a6-4640-b2b5-1711dc401092","code":"forbidden"}}
Last modified: 25 April 2026