Skip to navigation

Cost report

What model calls cost over time, by provider and model: one row per bucket, provider and model. It is cost alone, so it counts every cost recorded in the range, whether or not a run has revenue. For margin, use the margin report, which has no time axis. Costs are the ones recorded with trace() and POST /v1/costs.

Costs are in one currency. Send currency, or leave it out when every cost in the range is in one. If they are in more than one, the call returns 400 with parameter_invalid on currency.

Authentication

AuthorizationBearer

A secret key (rl_sk_test_..., rl_sk_live_...) or a restricted key with limited scopes (rl_rk_test_..., rl_rk_live_...). A restricted key can carry agent: true and an expires_at, and is what a coding agent should hold. Keys end in a checksum so secret scanners can recognize them. People create, roll and revoke keys in the dashboard; GET /v1/api_keys lists them, masked.

Query parameters

fromdatetimeRequired
Start of the range, inclusive.
todatetimeRequired
End of the range, exclusive.
group_byenumOptionalDefaults to month

The bucket size, in UTC (a week starts on Monday). Default month.

Allowed values:
customer_idstringOptional
Only objects belonging to this customer.
providerstringOptional

Only costs from this model provider, such as anthropic.

modelstringOptional
Only costs for this model.
currencystringOptional

Report in this currency (lowercase ISO 4217). Needed when the costs are in more than one.

Response

The report.
object"cost_report"
currencystring
fromdatetime
todatetime
group_byenum
Allowed values:
datalist of objects

Oldest bucket first, and the highest cost first within a bucket.

generated_atdatetime
livemodeboolean

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
429
Too Many Requests Error
500
Internal Server Error