Query API Key Usage
Query a Regular API Key's usage.
Request Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
start_date | Yes | None | UTC start date, inclusive |
end_date | Yes | None | UTC end date, inclusive |
granularity | No | daily | daily, hourly, or model |
limit | No | 100 | Bucket page size, 1–100 |
cursor | No | None | next_cursor returned by the previous page |
Response Example
{
"total_usage": 1.6,
"total_tokens": 12500,
"total_requests": 8,
"data": [
{
"start": "2026-08-04T00:00:00Z",
"usage": 1.6,
"tokens": 12500,
"requests": 8
}
],
"by_model": [
{
"model": "gpt-4.1",
"usage": 1.6,
"tokens": 12500,
"requests": 8
}
],
"complete": true,
"retention_start": "2026-08-01T00:00:00Z",
"cursor": "",
"has_more": false,
"next_cursor": null
}
Notes:
- The unit of
total_usageand each bucket'susageis US dollars; - When
granularity=model,dataelements use themodelfield instead ofstart; complete=falsemeans the retention watermark has not yet been established, or the query range is earlier than the current log retention scope;- When
has_more=true, the next page must use exactly the same key, date range, and granularity, and carrynext_cursor; - The usage snapshot is valid for 15 minutes. If the snapshot expires or the retention watermark changes,
409 usage_snapshot_expiredis returned; retry from the first page without the cursor; - If consumption logs are not enabled or details are unavailable,
503 usage_detail_unavailableis returned.
The usage snapshot is valid for 15 minutes. If the snapshot expires or the retention watermark changes, 409 usage_snapshot_expired is returned; re-query from the first page without the cursor. When has_more=true, the next page must use exactly the same key, date range, and granularity, and carry next_cursor.
For general request conventions, data structures, and error codes, see the Key Management API overview.