更新 API Key

PUT /api/v1/gateway/keys/{key_id}

更新 Key 的名称、模型白名单、限流或消费上限。只需传要修改的字段。需要管理员及以上角色(admin / ops / super)。

鉴权:本接口属于控制台后端 API(Base URL https://portal.aiin1.ai,注意不是 api.portal.aiin1.ai),需携带控制台账号登录后获取的 access_token(15 分钟有效),不能使用 sk-nex- API 令牌。登录方式见 账单对账与用量自动同步

请求参数

参数 位置 类型 必填 说明
key_id path string(uuid) Key ID

请求体

字段 类型 必填 说明
name string | null Key 名称
models_allowed array | null 可用模型白名单
allowed_ips array | null IP 白名单
rpm_limit integer | null 每分钟请求数上限
tpm_limit integer | null 每分钟 token 上限
spending_limit_usd number | string | null 累计消费上限(USD)

请求示例

curl -X PUT https://portal.aiin1.ai/api/v1/gateway/keys/KEY_ID \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "rpm_limit": 600 }'

响应

字段 类型 必填 说明
id string(uuid) Key ID
org_id string(uuid) 组织 ID
team_id string | null 所属团队 ID
name string Key 名称
key string | null 完整 Key,仅创建 / 轮换时返回一次
key_prefix string Key 前缀(列表展示用)
models_allowed array<string> 可用模型白名单(空数组 = 不限制)
rpm_limit integer 每分钟请求数上限
tpm_limit integer 每分钟 token 上限
is_sandbox boolean 是否沙箱 Key
allowed_ips array | null IP 白名单(null = 不限制)
spending_limit_usd string | null 累计消费上限(USD),null = 不限
expires_at string | null 过期时间
rotate_grace_until string | null 轮换后旧 Key 的宽限期截止时间
status string 状态
created_at string(datetime) 创建时间