跳转到主要内容
PATCH
/
api
/
v1
/
keys
/
{hash}
curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production-backend-v2",
    "limit": 200,
    "limit_reset": "monthly",
    "allowed_providers": ["openai", "anthropic", "google"],
    "allowed_models": ["openai/gpt-5.4", "anthropic/claude-sonnet-4.6", "google/gemini-2.5-flash"]
  }'
curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production-backend-v2",
    "limit": 200,
    "limit_reset": "monthly",
    "allowed_providers": ["openai", "anthropic", "google"],
    "allowed_models": ["openai/gpt-5.4", "anthropic/claude-sonnet-4.6", "google/gemini-2.5-flash"]
  }'
请求体中的所有字段均为可选——仅包含您想要更改的字段。

禁用 / 启用 Key

curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx" \
  -H "Content-Type: application/json" \
  -d '{"disabled": true}'
被禁用的 key 会立即停止接受请求。设置 disabled: false 可重新启用。

更新消费限额

curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "limit": 500,
    "limit_reset": "monthly"
  }'
limit 设置为 null 可移除消费上限。limit_reset 字段控制计数器何时重置:daily(UTC 午夜)、weekly(周一 UTC 午夜)或 monthly(每月 1 日 UTC 午夜)。设置为 null 表示终身上限。