Get Usage Report
Token usage in time buckets, optionally grouped by model, API key or context window.
Get your token usage over a time range, split into buckets of a minute, an hour or a day. Group the results by model, API key or context window to see where your tokens go.
GET /v1/account/usageFor dollar amounts, use request logs (cost per request) or billing transactions.
Buckets
Bucket edges are aligned to UTC: 1d buckets start at midnight UTC and
1h buckets on the hour. starting_at is rounded down to the start of
its bucket.
bucket_width | Default limit | Max limit |
|---|---|---|
1d | 7 | 31 |
1h | 24 | 168 |
1m | 60 | 1440 |
Every bucket in the range is returned, including buckets with no usage
(their results is empty). Without ending_at, the report runs up to
the bucket that contains the current time.
Query parameters
starting_atstringrequiredStart of the range (RFC 3339), rounded down to the start of its bucket.
ending_atstringoptionalEnd of the range (RFC 3339), exclusive. Only buckets that end by this time are returned.
bucket_widthstringoptionalDefault 1dSize of each bucket.
1d1h1mlimitintegeroptionalNumber of buckets per page. Default and maximum depend on
bucket_width (see Buckets).
pagestringoptionalThe next_page token from the previous response.
group_by[]string[]optionalSplit each bucket's results by these dimensions. Without it, each bucket has one result with the totals.
modelapi_key_idcontext_windowmodels[]string[]optionalOnly count requests to these models.
api_key_ids[]string[]optionalOnly count requests made with these API keys.
context_window[]string[]optionalOnly count requests whose input falls in these size ranges.
0-200k200k-1MArray parameters can be repeated, with or without brackets:
models[]=a&models[]=b and models=a&models=b are the same.
Response
dataBucket[]optionalOne entry per bucket, oldest first. Each has starting_at,
ending_at (RFC 3339) and results.
has_morebooleanoptionaltrue when more buckets remain in the range.
next_pagestring | nulloptionalPass as page to get the next buckets.
Result fields
uncached_input_tokensintegeroptionalInput tokens that were neither read from nor written to the prompt cache.
cache_read_input_tokensintegeroptionalInput tokens read from the prompt cache.
cache_creationobjectoptionalInput tokens written to the cache:
ephemeral_5m_input_tokens and ephemeral_1h_input_tokens.
output_tokensintegeroptionalOutput tokens.
modelstring | nulloptionalThe model, when grouped by model.
api_key_idstring | nulloptionalThe API key, when grouped by api_key_id.
context_windowstring | nulloptional0-200k or 200k-1M, when grouped by context_window.
Errors
| Status | Reason |
|---|---|
400 | starting_at is missing, a timestamp isn't RFC 3339, a value isn't allowed, limit is out of range, or page is invalid. |