List API key usage

http
GET /api-keys/usage

List API key usage.

Parameters

NameInRequiredDescription
presetqueryWhole local days, defaulting to 30d. Explicit from/to bounds take precedence over preset, including SDK-supplied defaults.
fromqueryInclusive start. Supply both from and to; these bounds take precedence over preset.
toqueryExclusive end, no later than the end of today in timezone.
timezonequery
granularityqueryUTC hours, or local calendar days, Monday-based weeks and months.
group_byqueryGrouping dimensions supported by this operation. Repeat the parameter or use a comma-separated list.
comparequeryCompare preceding calendar months for whole-month custom ranges, local days for whole-day ranges and presets, or equal elapsed duration otherwise.
project_referencequery

Responses

StatusDescription
200AI spending by API key; kind separates individual keys from grouped usage, including requests without API key authentication. With project_reference: the project’s keys, requests without a key, and usage from deleted key records. Without it: the caller’s own keys and requests without a key; usage of a deleted key record cannot be recovered. Read from the AI usage ledger; usd is the customer charge at the credit rate and never provider cost.
400Bad request
401Unauthorized
403Forbidden
404Not found
500Server error