跳轉到主要內容
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"]
  }'
import requests

resp = requests.patch(
    "https://api.arouter.ai/api/v1/keys/KEY_HASH",
    headers={"Authorization": "Bearer lr_mgmt_xxxx"},
    json={
        "name": "production-backend-v2",
        "limit": 200,
        "limit_reset": "monthly",
        "allowed_providers": ["openai", "anthropic", "google"],
    },
)
print(resp.json())
updated, err := client.UpdateKey(ctx, "KEY_HASH", &arouter.UpdateKeyRequest{
    Name:             stringPtr("production-backend-v2"),
    Limit:            float64Ptr(200),
    LimitReset:       stringPtr("monthly"),
    AllowedProviders: []string{"openai", "anthropic", "google"},
})
const updated = await router.updateKey("KEY_HASH", {
  name: "production-backend-v2",
  limit: 200,
  limit_reset: "monthly",
  allowed_providers: ["openai", "anthropic", "google"],
});
console.log(updated.data.name); // "production-backend-v2"
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"]
  }'
import requests

resp = requests.patch(
    "https://api.arouter.ai/api/v1/keys/KEY_HASH",
    headers={"Authorization": "Bearer lr_mgmt_xxxx"},
    json={
        "name": "production-backend-v2",
        "limit": 200,
        "limit_reset": "monthly",
        "allowed_providers": ["openai", "anthropic", "google"],
    },
)
print(resp.json())
updated, err := client.UpdateKey(ctx, "KEY_HASH", &arouter.UpdateKeyRequest{
    Name:             stringPtr("production-backend-v2"),
    Limit:            float64Ptr(200),
    LimitReset:       stringPtr("monthly"),
    AllowedProviders: []string{"openai", "anthropic", "google"},
})
const updated = await router.updateKey("KEY_HASH", {
  name: "production-backend-v2",
  limit: 200,
  limit_reset: "monthly",
  allowed_providers: ["openai", "anthropic", "google"],
});
console.log(updated.data.name); // "production-backend-v2"
請求體中的所有欄位均為可選——僅包含您想要變更的欄位。

停用 / 啟用 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 表示終身上限。