Get API key usage

http
GET /api-keys/{id}/usage

Read customer spend, calls and tokens for an API key.

Parameters

NameInRequiredDescription
idpathYes
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_referencequeryNarrow usage to one accessible project by UUID or slug. Required for member grouping.

Responses

StatusDescription
200Customer AI spending for one API key: totals, bucketed usage, model and deployment breakdowns, and requested groups/comparison. serving names recorded host/tier facts; null means no deployment was recorded. usd is the customer charge at the credit rate, excluding provider cost. All cuts use one read snapshot.
400Bad request
401Unauthorized
403Forbidden
404Not found
500Server error