创建新的 API key
为已认证账户创建新的 CometAPI API key。
使用此端点可为自动化、内部仪表板或服务端集成创建 API key。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 前缀。请求体
| Field | Type | Description |
|---|---|---|
name | string | key 的用户可读显示名称。必须不超过 50 个字符。 |
expired_time | integer | key 过期的 Unix 时间戳(秒)。使用 -1 表示永不过期。 |
remain_quota | integer | 以 CometAPI 内部配额单位表示的初始配额。如果该值达到 0 且 unlimited_quota 为 false,则使用此 key 发起的模型请求会因配额耗尽而被拒绝。 |
unlimited_quota | boolean | 该 key 是否绕过剩余配额检查。仅当希望该 key 在 remain_quota 为 0 时仍可继续工作时,才设置为 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.
请求体
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"
Unix timestamp in seconds when the key expires. Use -1 for no expiration. A past timestamp blocks model requests with this key.
-1
Starting quota for the new 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