创建 API Key

POST /api/v1/gateway/keys

创建一个新的 sk-nex- API Key。完整 Key 仅在本次响应中返回一次,请立即妥善保存。

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

请求体

字段 类型 必填 说明
name string Key 名称
team_id string | null 绑定到团队
models_allowed array<string> 可用模型白名单(缺省 = 不限制)
rpm_limit integer 每分钟请求数上限
tpm_limit integer 每分钟 token 上限
is_sandbox boolean 是否沙箱 Key
allowed_ips array | null IP 白名单(null = 不限制)
spending_limit_usd number | string | null 累计消费上限(USD),null = 不限
expires_at string | null 过期时间(ISO 8601)

请求示例

curl -X POST https://portal.aiin1.ai/api/v1/gateway/keys \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "name": "prod-backend", "rpm_limit": 300, "spending_limit_usd": 500 }'

响应

字段 类型 必填 说明
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) 创建时间