Get Usage Summary
/v1/billingReturns account usage and cost summary rows for a date range.
Use this endpoint to build account-level usage reports. By default it returns a daily summary for the last 30 days.
Authentication
Authorization Bearer
Send an API key (sk-...) in the Authorization header.
Query Parameters
typeenum<string>Usage query type.
groupenum<string>Grouping granularity.
start_daystringStart day in YYYY-MM-DD format. Defaults to 30 days before today UTC.
end_daystringEnd day in YYYY-MM-DD format. Defaults to today UTC.
model_idintegerOptional internal model id filter.
pageintegerPage number, starting at 1.
page_sizeintegerPage size from 1 to 200.
Response
codeintegerResponse status code.
dataobject[]Usage summary rows.
data.periodstringGrouped period label.
data.hour_id_startstringStart timestamp for the group.
data.hour_id_endstringEnd timestamp for the group.
data.wallet_amountnumberAmount charged to wallet balance.
data.credit_amountnumberAmount charged to credit balance.
data.total_amountnumberTotal charged amount.
data.input_tokensstringInput token count.
data.output_tokensstringOutput token count.
data.request_numstringNumber of billed requests.
data.image_countstringGenerated image count.
data.video_secondsnumberGenerated video seconds.
data.model_idstring | nullModel id when grouped by model.
Error Handling
- 401 / unauthenticated: missing or invalid
Authorization. - INVALID_BILLING_USAGE_PAGINATION:
pageorpage_sizeis out of range.