Console API: usage
This page is generated from server/api/openapi.yaml. Do not edit it by hand.
Usage records, aggregates, generation detail. Handlers: internal/console/usage.
GET /api/v1/usage
Section titled “GET /api/v1/usage”List usage records
operationId usageList · auth: orgSession
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
from |
query | string<date-time> | no | Inclusive lower bound. |
to |
query | string<date-time> | no | Exclusive upper bound. |
api_key_id |
query | string<uuid> | no | |
model |
query | string | no | Exact model slug. |
status |
query | UsageStatus | no | |
cursor |
query | string | no | Opaque cursor from a previous page’s next_cursor. |
limit |
query | integer<int32> | no | (minimum: 1, maximum: 200, default: 50) |
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json UsageRecordPage |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — UsageRecordPage
data(array of UsageRecord, required)request_id(string, required) — Also the generation id returned to API clients. created_at(string, required) api_key_id(string, required, nullable) api_key_name(string, required) — Empty when the key no longer exists.model(string, required)provider(string, required) — Provider tag of the channel that served the request; may be empty.operation(Operation, required)stream(boolean, required)status(UsageStatus, required)finish_reason(string, required)usage(UsageCounters, required) — Disjoint usage counters of one request; absent counters are zero.input_tokens(integer) output_tokens(integer) reasoning_tokens(integer) cache_read_tokens(integer) cache_write_5m_tokens(integer) cache_write_1h_tokens(integer) image_input_tokens(integer) image_output_tokens(integer) audio_input_tokens(integer) audio_output_tokens(integer) input_chars(integer) audio_input_ms(integer) images(integer) web_search_calls(integer) requests(integer) video_ms(integer) — Milliseconds of generated video (asynchronous video tasks).
estimated(boolean, required) — Usage was estimated locally because the upstream did not report it.cost_nano(string, required, pattern: ”^-?[0-9]+$”) — Amount charged. (Nano-USD, integer string.)list_nano(string, required, pattern: ”^-?[0-9]+$”) — Amount at list price, before the organisation discount. (Nano-USD, integer string.)discount_ppm(integer, required) attempts(integer, required) — Upstream attempts; retries = attempts - 1. ttft_ms(integer, required, nullable) — Time to first token; null when nothing was delivered. duration_ms(integer, required) compensation(object, required) — What a settled request earned under the SLA rules. Written asynchronously; null on a usage record means “nothing so far”.rule_kind(SlaRuleKind, required) — upstream_5xx: every supply failed and the client saw a 5xx. ttft: time to first content abovethresholdms. throughput: output tokens per second of generation time belowthreshold. empty: a successful chat response with no output.status(SlaCompensationStatus, required) — granted: credits were granted. capped: the organisation’s daily cap was used up. zero_amount: the computed amount was 0 (for example a 5xx that cost nothing). key_paused: compensation of the API key is paused.amount_nano(string, required, pattern: ”^-?[0-9]+$”) — Credits granted. (Nano-USD, integer string.)detail(string, required) — Observed value against the threshold.
byok_key_id(string, nullable) — Set when the request was served with the organisation’s own provider key (BYOK). cost_nanois then only the service fee.byok_upstream_cost_nano(string, pattern: ”^-?[0-9]+$”, nullable) — What the provider charged the organisation for a BYOK request, estimated at the offering’s cost price; for display only, never charged by the platform. (Nano-USD, integer string.)
next_cursor(string, required, nullable) — Pass ascursorto fetch the next page; null on the last page.has_more(boolean, required)
GET /api/v1/usage/aggregate
Section titled “GET /api/v1/usage/aggregate”Usage summed into time buckets (charts)
operationId usageAggregate · auth: orgSession
| 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 UsageAggregate |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — UsageAggregate
bucket(“hour” | “day”, required)group_by(“none” | “model” | “api_key”, required)from(string, required) to(string, required) data(array of UsageBucket, required)start(string, required) — Start of the time bucket (UTC). key(string, required) — Group value (model slug or API key id); empty when ungrouped.label(string, required) — Display label of the group (model name or API key name).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/v1/usage/summary
Section titled “GET /api/v1/usage/summary”Spend today, this month and lifetime
operationId usageSummary · auth: orgSession
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json UsageSummary |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — UsageSummary
day_cost_nano(string, required, pattern: ”^-?[0-9]+$”) — Current UTC day. (Nano-USD, integer string.)month_cost_nano(string, required, pattern: ”^-?[0-9]+$”) — Current UTC calendar month. (Nano-USD, integer string.)lifetime_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/v1/usage/{request_id}
Section titled “GET /api/v1/usage/{request_id}”Generation detail with itemised cost
operationId usageGet · auth: orgSession
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
request_id |
path | string<uuid> | yes |
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json Generation |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — Generation
request_id(string, required) — Also the generation id returned to API clients. created_at(string, required) api_key_id(string, required, nullable) api_key_name(string, required) — Empty when the key no longer exists.model(string, required)provider(string, required) — Provider tag of the channel that served the request; may be empty.operation(Operation, required)stream(boolean, required)status(UsageStatus, required)finish_reason(string, required)usage(UsageCounters, required) — Disjoint usage counters of one request; absent counters are zero.input_tokens(integer) output_tokens(integer) reasoning_tokens(integer) cache_read_tokens(integer) cache_write_5m_tokens(integer) cache_write_1h_tokens(integer) image_input_tokens(integer) image_output_tokens(integer) audio_input_tokens(integer) audio_output_tokens(integer) input_chars(integer) audio_input_ms(integer) images(integer) web_search_calls(integer) requests(integer) video_ms(integer) — Milliseconds of generated video (asynchronous video tasks).
estimated(boolean, required) — Usage was estimated locally because the upstream did not report it.cost_nano(string, required, pattern: ”^-?[0-9]+$”) — Amount charged. (Nano-USD, integer string.)list_nano(string, required, pattern: ”^-?[0-9]+$”) — Amount at list price, before the organisation discount. (Nano-USD, integer string.)discount_ppm(integer, required) attempts(integer, required) — Upstream attempts; retries = attempts - 1. ttft_ms(integer, required, nullable) — Time to first token; null when nothing was delivered. duration_ms(integer, required) compensation(object, required) — What a settled request earned under the SLA rules. Written asynchronously; null on a usage record means “nothing so far”.rule_kind(SlaRuleKind, required) — upstream_5xx: every supply failed and the client saw a 5xx. ttft: time to first content abovethresholdms. throughput: output tokens per second of generation time belowthreshold. empty: a successful chat response with no output.status(SlaCompensationStatus, required) — granted: credits were granted. capped: the organisation’s daily cap was used up. zero_amount: the computed amount was 0 (for example a 5xx that cost nothing). key_paused: compensation of the API key is paused.amount_nano(string, required, pattern: ”^-?[0-9]+$”) — Credits granted. (Nano-USD, integer string.)detail(string, required) — Observed value against the threshold.
breakdown(array of CostLineItem, required)kind(CostItemKind, required) — Kind of a cost line.byok_service_feeis the only line of a request served with the organisation’s own provider key (BYOK); its amount is the platform’s service fee.quantity(integer, required) — The counter: tokens for per_million, items for each, MILLISECONDS for per_second (divide by 1000 before multiplying by unit_price). unit_price(string, required) — List price in nano-USD in the given unit, before discount (integer string).unit(“per_million” | “each” | “per_second”, required)amount_nano(string, required, pattern: ”^-?[0-9]+$”) — This line’s share of the charged total. (Nano-USD, integer string.)
price_version_id(string, required, nullable) byok_key_id(string, nullable) — Set when the request was served with the organisation’s own provider key (BYOK). cost_nanois then only the service fee.byok_upstream_cost_nano(string, pattern: ”^-?[0-9]+$”, nullable) — What the provider charged the organisation for a BYOK request, estimated at the offering’s cost price; for display only, never charged by the platform. (Nano-USD, integer string.)routing(array of RoutingAttempt) — Upstream attempts of the request in order (provider tag, model, outcome). The last delivered one served the response; a BYOK attempt used the organisation’s own key.attempt(integer, required) — 1-based attempt number. provider(string, required) — Provider tag of the channel; may be empty.model(string, required) — Model name as sent to the upstream.outcome(string, required) — Outcome class of the attempt (for example success, server_error, rate_limited, timeout, auth).delivered(boolean, required) — Its output reached the client.byok(boolean, required) — The attempt used the organisation’s own provider key.http_status(integer) — Upstream HTTP status; 0 when none.