控制台 API: mgmt
本页由 server/api/openapi.yaml 生成,内容为英文,请勿手工修改。
Management API (V3 R5), served under /api/mgmt/v1 and authenticated with a management key
(Authorization: Bearer mk-…), never with a session or an inference key (sk-…); a management key never
authenticates the relay either. Generated separately (internal/mgmtapi/gen, api/oapi-codegen-mgmt.yaml); the
console router excludes this tag. Handlers: internal/mgmtapi/handler.
A key acts with the permissions its creator has in the organisation at the time of the request, narrowed by
its scope: read (balance, usage, list keys) or manage_keys (also create and revoke inference keys). Rate
limits are per management key and minute (reads 120, writes 30; 429 with Retry-After); failed
authentications are limited per client address. Every call is recorded in the organisation’s audit trail.
GET /api/mgmt/v1/whoami
Section titled “GET /api/mgmt/v1/whoami”The calling management key
operationId mgmtWhoami · auth: mgmtKey
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json MgmtWhoami |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — MgmtWhoami
key_id(string, required) org_id(string, required) name(string, required)scope(MgmtScope, required) —read: balance, usage, list inference keys.manage_keys: also create and revoke inference keys.expires_at(string, required, nullable)
GET /api/mgmt/v1/balance
Section titled “GET /api/mgmt/v1/balance”Balance, split into top-up, bonus and subscription credits
operationId mgmtGetBalance · auth: mgmtKey
Scope read; the key’s creator needs billing view permission. topup.remaining_nano + bonus.remaining_nano + subscription.remaining_nano = total_nano always holds (all read in one snapshot). bonus is promotional and
referral credit (not refundable). spendable_nano = total_nano − debt_nano.
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json MgmtBalance |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — MgmtBalance
total_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.topup(MgmtBalancePart, required)remaining_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.next_expires_at(string, required, nullable) — Earliest expiry among this part’s credits; null when none of them expires. next_expiring_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.
bonus(MgmtBalancePart, required)remaining_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.next_expires_at(string, required, nullable) — Earliest expiry among this part’s credits; null when none of them expires. next_expiring_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.
subscription(MgmtBalancePart, required)remaining_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.next_expires_at(string, required, nullable) — Earliest expiry among this part’s credits; null when none of them expires. next_expiring_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.
debt_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.spendable_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.as_of(string, required)
GET /api/mgmt/v1/usage
Section titled “GET /api/mgmt/v1/usage”Usage aggregated into hourly or daily buckets
operationId mgmtGetUsage · auth: mgmtKey
Scope read; the key’s creator needs usage view permission. from and to are required; at most 31 days for hourly and 366 days for daily buckets.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
from |
query | string<date-time> | yes | Inclusive lower bound. |
to |
query | string<date-time> | yes | Exclusive upper bound. |
bucket |
query | “hour” \ | “day” | no |
group_by |
query | “none” \ | “model” \ | “api_key” |
api_key_id |
query | string<uuid> | no | |
model |
query | string | no |
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json MgmtUsage |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — MgmtUsage
from(string, required) to(string, required) bucket(“hour” | “day”, required)group_by(“none” | “model” | “api_key”, required)data(array of MgmtUsageRow, required)start(string, required) key(string, required) — Model slug or API key id when grouped; empty otherwise.requests(integer, required) input_tokens(integer, required) output_tokens(integer, required) cost_nano(NanoUSD, required, pattern: ”^-?[0-9]+$”) — An amount of money in nano-USD (1 USD = 1,000,000,000) as a decimal integer string. It is a string because an int64 does not survive JavaScript numbers. Never a float.
GET /api/mgmt/v1/keys
Section titled “GET /api/mgmt/v1/keys”List inference API keys
operationId mgmtListKeys · auth: mgmtKey
Scope read. The keys the creator may see (all keys, or only their own).
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json ApiKeyList |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — ApiKeyList
data(array of ApiKey, required)id(string, required) name(string, required)key_prefix(string, required) — First 10 characters, e.g.sk-AbCd123.key_last4(string, required)status(ApiKeyStatus, required)created_by(string, required, nullable) expires_at(string, required, nullable) spend_limit_nano(string, required, pattern: ”^-?[0-9]+$”, nullable) — Nano-USD as a decimal integer string; null when not set.spend_window(SpendWindow, required) — Calendar windows are UTC.spent_nano(string, required, pattern: ”^-?[0-9]+$”) — Spend in the current window. (Nano-USD, integer string.)model_allowlist(array of string, required, nullable) — Model slugs, a trailing*is a prefix wildcard; null = all models.ip_allowlist(array of string, required, nullable) — CIDR prefixes; null = any address.limits(RateLimits, required) — Rate limits; 0 means unlimited for that dimension.rpm(integer, required) — Requests per minute. tpm(integer, required) — Tokens per minute. concurrency(integer, required) — Simultaneous in-flight requests.
last_used_at(string, required, nullable) created_at(string, required) updated_at(string, required)
POST /api/mgmt/v1/keys
Section titled “POST /api/mgmt/v1/keys”Create an inference API key
operationId mgmtCreateKey · auth: mgmtKey
Scope manage_keys. The key is created on behalf of the management key’s creator. The plaintext secret is in this response only.
Request body (required) application/json — ApiKeyInput
name(string, required, minLength: 1, maxLength: 80)expires_at(string, nullable) spend_limit_nano(string, pattern: ”^-?[0-9]+$”, nullable) — Nano-USD as a decimal integer string; null when not set.spend_window(SpendWindow) — Calendar windows are UTC.model_allowlist(array of string, nullable)ip_allowlist(array of string, nullable)limits(RateLimits) — Rate limits; 0 means unlimited for that dimension.rpm(integer, required) — Requests per minute. tpm(integer, required) — Tokens per minute. concurrency(integer, required) — Simultaneous in-flight requests.
| Status | Meaning | Body |
|---|---|---|
| 201 | OK | application/json ApiKeyCreated |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 201 application/json — ApiKeyCreated
key(ApiKey, required) — An API key without its secret.id(string, required) name(string, required)key_prefix(string, required) — First 10 characters, e.g.sk-AbCd123.key_last4(string, required)status(ApiKeyStatus, required)created_by(string, required, nullable) expires_at(string, required, nullable) spend_limit_nano(string, required, pattern: ”^-?[0-9]+$”, nullable) — Nano-USD as a decimal integer string; null when not set.spend_window(SpendWindow, required) — Calendar windows are UTC.spent_nano(string, required, pattern: ”^-?[0-9]+$”) — Spend in the current window. (Nano-USD, integer string.)model_allowlist(array of string, required, nullable) — Model slugs, a trailing*is a prefix wildcard; null = all models.ip_allowlist(array of string, required, nullable) — CIDR prefixes; null = any address.limits(RateLimits, required) — Rate limits; 0 means unlimited for that dimension.rpm(integer, required) — Requests per minute. tpm(integer, required) — Tokens per minute. concurrency(integer, required) — Simultaneous in-flight requests.
last_used_at(string, required, nullable) created_at(string, required) updated_at(string, required)
secret(string, required) — The plaintext key. Returned once, never again.
GET /api/mgmt/v1/keys/{key_id}
Section titled “GET /api/mgmt/v1/keys/{key_id}”Get an inference API key
operationId mgmtGetKey · auth: mgmtKey
Scope read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
key_id |
path | string<uuid> | yes |
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json ApiKey |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — ApiKey
id(string, required) name(string, required)key_prefix(string, required) — First 10 characters, e.g.sk-AbCd123.key_last4(string, required)status(ApiKeyStatus, required)created_by(string, required, nullable) expires_at(string, required, nullable) spend_limit_nano(string, required, pattern: ”^-?[0-9]+$”, nullable) — Nano-USD as a decimal integer string; null when not set.spend_window(SpendWindow, required) — Calendar windows are UTC.spent_nano(string, required, pattern: ”^-?[0-9]+$”) — Spend in the current window. (Nano-USD, integer string.)model_allowlist(array of string, required, nullable) — Model slugs, a trailing*is a prefix wildcard; null = all models.ip_allowlist(array of string, required, nullable) — CIDR prefixes; null = any address.limits(RateLimits, required) — Rate limits; 0 means unlimited for that dimension.rpm(integer, required) — Requests per minute. tpm(integer, required) — Tokens per minute. concurrency(integer, required) — Simultaneous in-flight requests.
last_used_at(string, required, nullable) created_at(string, required) updated_at(string, required)
POST /api/mgmt/v1/keys/{key_id}/revoke
Section titled “POST /api/mgmt/v1/keys/{key_id}/revoke”Revoke an inference API key
operationId mgmtRevokeKey · auth: mgmtKey
Scope manage_keys. Permanent.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
key_id |
path | string<uuid> | yes |
| Status | Meaning | Body |
|---|---|---|
| 204 | Revoked | — |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |