Get the workspace's usage report
Usage summed per bucket of the span and per value of each group_by dimension, split by kind and by how it was priced: rated usage a charge landed with, byok calls through the workspace’s own model provider, and unrated usage no rate priced. Usage counts toward the instant it is accounted at, which is when it occurred unless it was recorded after that instant was final. A row whose ending_at is at or before finalized_before never changes again, so re-reading only the rows after it, and taking the difference from what was read before, accounts every row exactly once.
GET
/v1/workspaces/{workspace_id}/usage-reportAuthorization
AuthorizationBearer token · headerrequiredPath parameters
workspace_idstring<uuid>requiredWorkspace id
Query parameters
starting_atstring<date-time>requiredThe span's start, inclusive: usage accounted at or after it.
ending_atstring<date-time>requiredThe span's end, exclusive. A span covers at most 31 days at `all` or
`1d` and at most 7 days at `1h`.
bucket_widthBucketWidthParamHow finely to cut the span: `all`, the default, makes it one bucket;
`1d` and `1h` cut it per UTC day or hour, and need `starting_at` and
`ending_at` on those boundaries.
Allowed:
all1d1hgroup_bystring[]What to sum separately for each value of, repeated in the order rows
sort by: `kind`, `model_provider_id`, `model`, `session_id`, or
`metadata.<key>`. At most 8. Omitted, each bucket is one row.
limitinteger<int64>Rows on the page. Defaults to 100.
min 1 · max 1000
afterstringThe previous page's `next_cursor`. The other parameters must be the
ones that page was read with.
metadataobjectOnly rows whose metadata holds each pair, matched exactly:
`metadata[tenant_id]=t_123`. Several pairs must all hold.
Responses
200One page of the report.
finalized_beforestring<date-time> | nullrequiredA row whose `ending_at` is at or before this instant is final and
never changes again; a later one may still grow. Null until any usage
is final.
itemsUsageReportRowBody[]requiredOrdered by `starting_at`, then by each `group_by` value in turn,
bytewise, with no value last. A combination with no usage has no row.
Show propertiesHide properties
Array of
UsageReportRowBodyending_atstring<date-time>requiredkindstringThe usage kind, such as `llm_tokens` or `storage`. An open
vocabulary: a kind Subako starts measuring later arrives under its
own name, so a client keeps a value it does not know rather than
rejecting the row.
metadataobjectOne entry per `metadata.<key>` grouped by.
modelstring | nullmodel_provider_idstring<uuid> | nullsession_idstring<uuid> | nullstarting_atstring<date-time>requiredusageUsageSummaryBodyrequiredWhat a row's usage came to, kind by kind. A kind with no usage is absent,
and a kind added later arrives as a field of its own, which a client that
does not know it ignores.
Show propertiesHide properties
costinteger<int64>requiredHundred-millionths of a credit: every `rated` cost below, summed.
function_runtimeRuntimeSummaryBodyRun time by how it was priced. A class with none is absent.
Show propertiesHide properties
ratedRatedDurationBodyShow propertiesHide properties
costinteger<int64>requiredHundred-millionths of a credit.
duration_msinteger<int64>requiredunratedDurationBodyTime a charge was due for but no rate priced.
Show propertiesHide properties
duration_msinteger<int64>requiredharness_runtimeRuntimeSummaryBodyRun time by how it was priced. A class with none is absent.
Show propertiesHide properties
ratedRatedDurationBodyShow propertiesHide properties
costinteger<int64>requiredHundred-millionths of a credit.
duration_msinteger<int64>requiredunratedDurationBodyTime a charge was due for but no rate priced.
Show propertiesHide properties
duration_msinteger<int64>requiredllm_tokensLlmTokensSummaryBodyModel calls by how they were priced. A class with no calls is absent.
Show propertiesHide properties
byokTokensBodyCalls no charge landed with.
Show propertiesHide properties
tokensTokenTotalsBodyrequiredToken counts summed per format, each field on its own: the formats count
different things, so they are never added together. A format with no
calls is absent.
Show propertiesHide properties
anthropicAnthropicUsageBodyShow propertiesHide properties
cache_creation_input_tokensinteger<int64>requiredcache_read_input_tokensinteger<int64>requiredinput_tokensinteger<int64>requiredoutput_tokensinteger<int64>requiredopenai_responsesOpenaiResponsesUsageBodyShow propertiesHide properties
cache_write_input_tokensinteger<int64>requiredcached_input_tokensinteger<int64>requiredinput_tokensinteger<int64>requiredoutput_tokensinteger<int64>requiredreasoning_output_tokensinteger<int64>requiredratedRatedTokensBodyCalls a charge landed with.
Show propertiesHide properties
costinteger<int64>requiredHundred-millionths of a credit, across formats.
tokensTokenTotalsBodyrequiredToken counts summed per format, each field on its own: the formats count
different things, so they are never added together. A format with no
calls is absent.
Show propertiesHide properties
anthropicAnthropicUsageBodyShow propertiesHide properties
cache_creation_input_tokensinteger<int64>requiredcache_read_input_tokensinteger<int64>requiredinput_tokensinteger<int64>requiredoutput_tokensinteger<int64>requiredopenai_responsesOpenaiResponsesUsageBodyShow propertiesHide properties
cache_write_input_tokensinteger<int64>requiredcached_input_tokensinteger<int64>requiredinput_tokensinteger<int64>requiredoutput_tokensinteger<int64>requiredreasoning_output_tokensinteger<int64>requiredunratedTokensBodyCalls no charge landed with.
Show propertiesHide properties
tokensTokenTotalsBodyrequiredToken counts summed per format, each field on its own: the formats count
different things, so they are never added together. A format with no
calls is absent.
Show propertiesHide properties
anthropicAnthropicUsageBodyShow propertiesHide properties
cache_creation_input_tokensinteger<int64>requiredcache_read_input_tokensinteger<int64>requiredinput_tokensinteger<int64>requiredoutput_tokensinteger<int64>requiredopenai_responsesOpenaiResponsesUsageBodyShow propertiesHide properties
cache_write_input_tokensinteger<int64>requiredcached_input_tokensinteger<int64>requiredinput_tokensinteger<int64>requiredoutput_tokensinteger<int64>requiredreasoning_output_tokensinteger<int64>requiredsandbox_runtimeRuntimeSummaryBodyRun time by how it was priced. A class with none is absent.
Show propertiesHide properties
ratedRatedDurationBodyShow propertiesHide properties
costinteger<int64>requiredHundred-millionths of a credit.
duration_msinteger<int64>requiredunratedDurationBodyTime a charge was due for but no rate priced.
Show propertiesHide properties
duration_msinteger<int64>requiredstorageStorageSummaryBodyStorage held, archives and volumes together, by how it was priced. A
class with none is absent.
Show propertiesHide properties
ratedRatedStorageBodyShow propertiesHide properties
byte_hoursinteger<int64>requiredBytes held times hours held, rounded down.
costinteger<int64>requiredHundred-millionths of a credit.
unratedStorageBodyStorage a charge was due for but no rate priced.
Show propertiesHide properties
byte_hoursinteger<int64>requiredBytes held times hours held, rounded down.
volume_writeVolumeWriteSummaryBodyBytes written to volumes by how they were priced. A class with none is
absent.
Show propertiesHide properties
ratedRatedBytesBodyShow propertiesHide properties
bytesinteger<int64>requiredcostinteger<int64>requiredHundred-millionths of a credit.
unratedBytesBodyBytes a charge was due for but no rate priced.
Show propertiesHide properties
bytesinteger<int64>requirednext_cursorstring | nullrequiredPass as `after`, with the same other parameters, for the next page;
null on the last.
400A parameter missing, malformed, or out of bounds; a span longer than its bucket width allows or off its boundaries; a cursor from another query; or a report that ran too long, which a narrower span, grouping, or filter avoids.
errorErrorDetailrequiredWhat went wrong: a `code` to branch on and a `message` to show. The
message is written for a person and may change; the code will not.
Show propertiesHide properties
codeErrorCoderequiredThe machine-readable half of an error response, and the field a client
branches on. Closed: every error carries exactly one of these.
Allowed:
unauthorizedforbiddennot_foundinvalid_requestconflictclient_outdatedprecondition_failedtoo_many_requestsinternalmessagestringrequired401Missing, malformed, or invalid bearer token.
errorErrorDetailrequiredWhat went wrong: a `code` to branch on and a `message` to show. The
message is written for a person and may change; the code will not.
Show propertiesHide properties
codeErrorCoderequiredThe machine-readable half of an error response, and the field a client
branches on. Closed: every error carries exactly one of these.
Allowed:
unauthorizedforbiddennot_foundinvalid_requestconflictclient_outdatedprecondition_failedtoo_many_requestsinternalmessagestringrequired403Caller lacks usage.read.
errorErrorDetailrequiredWhat went wrong: a `code` to branch on and a `message` to show. The
message is written for a person and may change; the code will not.
Show propertiesHide properties
codeErrorCoderequiredThe machine-readable half of an error response, and the field a client
branches on. Closed: every error carries exactly one of these.
Allowed:
unauthorizedforbiddennot_foundinvalid_requestconflictclient_outdatedprecondition_failedtoo_many_requestsinternalmessagestringrequired404No such workspace, or the caller cannot see it. An API key sees only its own workspace.
errorErrorDetailrequiredWhat went wrong: a `code` to branch on and a `message` to show. The
message is written for a person and may change; the code will not.
Show propertiesHide properties
codeErrorCoderequiredThe machine-readable half of an error response, and the field a client
branches on. Closed: every error carries exactly one of these.
Allowed:
unauthorizedforbiddennot_foundinvalid_requestconflictclient_outdatedprecondition_failedtoo_many_requestsinternalmessagestringrequired429The organization is already running two reports, or this server's report connections are all busy.
errorErrorDetailrequiredWhat went wrong: a `code` to branch on and a `message` to show. The
message is written for a person and may change; the code will not.
Show propertiesHide properties
codeErrorCoderequiredThe machine-readable half of an error response, and the field a client
branches on. Closed: every error carries exactly one of these.
Allowed:
unauthorizedforbiddennot_foundinvalid_requestconflictclient_outdatedprecondition_failedtoo_many_requestsinternalmessagestringrequired