Cost Data API

Get organization-wide cost breakdown by model

Returns organization-wide cost aggregation grouped by AI model (gpt-4o, claude-3-5-sonnet, etc.). Call it with a GET request to /cost-data/by-model, authenticated with a restricted API key and the "costs:read" scope.

Returns organization-wide cost aggregation grouped by AI model (gpt-4o, claude-3-5-sonnet, etc.). All models are returned (no truncation), so entries always sum to total_cost. Requests count toward your per-API-key rate limit; sustained overruns return 429 with the standard error envelope.

Authentication and scopes

Authenticate with a restricted API key in the Authorization: Bearer <key> header. This endpoint requires the costs:read scope.

Parameters

NameInTypeRequiredDescription
start_datequerystringYesStart of date range (ISO 8601, inclusive). Must be before end_date.
end_datequerystringYesEnd of date range (ISO 8601, exclusive).

Response fields

Fields returned in the 200 response body. Nested objects are listed under their parent. A field marked optional may be absent from the body; one marked nullable is always present but its value may be null.

FieldTypeDescription
modelsobject[]Cost breakdown by model.
model_slugstringModel slug.
provider_slugstringProvider slug; 'unknown' when the model could not be matched to a catalog provider.
total_coststringTotal cost for this model.
input_tokensnumber (double)Input tokens used.
output_tokensnumber (double)Output tokens used.
cache_creation_input_tokensnumber (double) nullableCache-creation input tokens; null = provider did not report.
cache_read_input_tokensnumber (double) nullableCache-read input tokens; null = provider did not report.
reasoning_tokensnumber (double) nullableReasoning tokens; null = not reported.
input_coststringInput cost (USD, decimal string).
output_coststringOutput cost (USD, decimal string).
cache_creation_coststring nullableCache-creation cost (USD string); null = not reported.
cache_read_coststring nullableCache-read cost (USD string); null = not reported.
reasoning_coststring nullableReasoning cost (USD string); null = not reported.
event_countnumber (double)Number of events.
percent_of_totalnumber (double)Percentage of total organization cost.
total_coststringTotal cost across all models.

Error codes

Errors return the standard error envelope with a code, message, and a correlationId you can quote to support.

StatusWhen it happens
400Invalid request data. Ensure start_date and end_date are valid ISO 8601 dates and start_date is before end_date.
401Missing or invalid API key. Send your key as Authorization: Bearer YOUR_API_KEY.
403API key lacks the costs:read scope. Create or update a key with the costs:read scope, then retry.
429Rate limit exceeded. The general API tier allows 100 requests per 15 minutes; wait for the window to reset before retrying.

Rate limits and retries

Rate limit exceeded. The general API tier allows 100 requests per 15 minutes; wait for the window to reset before retrying.