Skip to main content
GET /v1/usage authenticates with Authorization: Bearer <API Key> or x-api-key; no login JWT or user_id parameter is needed. The backend derives user and project identity from the key and aggregates only that key. A shared organization key returns combined usage across callers, not per-member or organization-wide totals. The response user_id identifies the user associated with the key. Required start and end use YYYY-MM-DD, inclusive in Beijing time (UTC+8), up to 366 calendar days. Missing, invalid or reversed dates return 400; an invalid or expired key returns 401; IP restrictions or incomplete authenticated identity return 403.
requests counts billing-visible usage records, excluding adjustments and empty attempt logs; it is not all HTTP attempts. Records need nonzero tokens, cache counters or spend, or a settled image billing snapshot. prompt_tokens, completion_tokens and total_tokens are recorded input, output and total tokens. cache_creation_input_tokens and cache_read_input_tokens are recorded cache counters; do not add them to total tokens again. price_micros is net settled USD spend: divide by 1,000,000 for dollars. It includes refunds and adjustments, can be negative, and excludes provider costs. Facts are counted by creation date; adjustments use their own creation date. Tokenless image/video requests may still incur spend. Empty ranges return zeros. unsettled_requests counts persisted but unconfirmed usage records excluded from other totals. Async writes and later settlement can change results; zero does not guarantee that every call has arrived. Each Relay process allows an average of one query per key every 5 seconds, burst 5. Back off after 429; retry 500/503 later. Queries do not incur charges.