更新 API key
通过在 JSON 请求体中发送 key ID 和可编辑字段来更新 CometAPI API key。
使用此端点更新 API key 的名称、状态、额度、过期时间、模型限制、IP 允许列表以及分组设置。Documentation Index
Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
Use this file to discover all available pages before exploring further.
Authorization 请求头值发送。不要添加 Bearer 前缀。请求体
| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 必填。由列出 API key返回的 API key ID。 |
name | string | 用户可读的 key 显示名称。长度必须不超过 50 个字符。 |
status | integer | 运行状态。1 表示启用该 key 用于模型请求。2 表示禁用。3 表示已过期。4 表示额度已用尽。被禁用、已过期或额度耗尽的 key 会被模型端点拒绝。 |
expired_time | integer | key 过期的 Unix 秒级时间戳。使用 -1 表示永不过期。过去的时间戳会阻止模型请求。 |
remain_quota | integer | CometAPI 内部额度单位中的剩余额度。如果该值达到 0 且 unlimited_quota 为 false,则使用此 key 的模型请求会因额度耗尽而被拒绝。 |
unlimited_quota | boolean | 该 key 是否绕过剩余额度检查。仅当即使 remain_quota 为 0,该 key 也应继续可用时,才设置为 true。 |
model_limits_enabled | boolean | 是否将此 key 限制为仅可使用特定模型。当为 false 时,将忽略 model_limits。 |
model_limits | string | 当 model_limits_enabled 为 true 时,此 key 允许使用的、以逗号分隔的 model ID。请使用 /v1/models 返回的 model ID;使用空字符串表示不限制模型。 |
allow_ips | string or null | 可选的 IP 允许列表。提供一个 JSON 字符串,并使用换行符(\n)分隔各条目。每个条目可以是单个 IPv4 地址、单个 IPv6 地址、IPv4 CIDR 或 IPv6 CIDR。使用 null 或 "" 可禁用 IP 限制。 |
group | string | 可选的账户分组限制。使用空字符串表示不显式指定分组。非空值必须是该账户可用的分组,否则 API 会返回 success: false。 |
cross_group_retry | boolean | 是否启用跨分组重试以进行自动分组路由。仅当该 key 使用自动路由分组时,此项才有意义。 |
允许列表格式
要允许多个 IP 或 CIDR 范围,请将它们作为一个 JSON 字符串发送,并在条目之间使用\n 分隔:
授权
Personal access token copied from CometAPI Console > Personal Settings. Send the raw token value; do not prefix it with Bearer.
请求体
Numeric API key ID returned by the list endpoint. For updates, send this value in the JSON body, not in the URL.
1234
User-readable display name for the API key. The backend accepts up to 50 Unicode characters; longer names return success: false with token name is too long.
50"production"
Operational status for the key. 1 enables the key for model requests, 2 disables it, 3 marks it expired, and 4 marks it quota exhausted. Disabled, expired, or exhausted keys are rejected by model endpoints.
1, 2, 3, 4 1
Unix timestamp in seconds when the key expires. Use -1 for no expiration. A past timestamp blocks model requests with this key.
-1
Remaining quota to assign to the key in CometAPI internal quota units. If this reaches 0 while unlimited_quota is false, model requests with this key are rejected as quota exhausted.
100000
Whether the key bypasses remaining-quota checks. Set true only when the key should keep working even if remain_quota is 0.
false
Whether to restrict this key to specific models. When true, only model IDs listed in model_limits are allowed. When false, model_limits is ignored.
false
Comma-separated model IDs allowed by this key when model_limits_enabled is true. Use model IDs returned by /v1/models, for example <model-id-1>,<model-id-2>. Use an empty string for no model restriction.
""
Optional IP allowlist. Provide one JSON string with entries separated by newline characters (\n). Each entry can be a single IPv4 address, single IPv6 address, IPv4 CIDR, or IPv6 CIDR. Example for three allowlist entries: 198.51.100.10\n203.0.113.0/24\n2001:db8::/32. CometAPI compares the model request client IP to this list. Use null or "" to disable IP restrictions.
"198.51.100.10\n203.0.113.0/24\n2001:db8::/32"
Optional account group restriction. Use an empty string for no explicit group restriction. Non-empty values must be available to the account, or the API returns success: false with a no access to group message.
""
Whether cross-group retry is enabled for automatic group routing. This is only meaningful when the key uses an auto-routed group such as auto.
false