Skip to main content

cost_reports

Creates, updates, deletes, gets or lists a cost_reports resource.

Overview

Namecost_reports
TypeResource
Idanthropic_admin.cost.cost_reports

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
ending_atstringEnd of the time bucket (exclusive) in RFC 3339 format.
resultsarrayList of cost items for this time bucket; multiple items when one or more `group_by[]` parameters are specified.
starting_atstringStart of the time bucket (inclusive) in RFC 3339 format.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectstarting_atending_at, bucket_width, group_by[]Get a cost report bucketed by day, optionally grouped by workspace_id and/or description. Costs are USD decimal strings in lowest currency units (cents).

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
starting_atstringTime buckets that start on or after this RFC 3339 timestamp will be returned. Snapped to the start of the day in UTC.
bucket_widthstringTime granularity of the response data. Only 1d is supported.
ending_atstringTime buckets that end before this RFC 3339 timestamp will be returned.
group_by[]arrayGroup by any subset of description and workspace_id. When grouping by description, responses include parsed fields like model and cost_type.

SELECT examples

Get a cost report bucketed by day, optionally grouped by workspace_id and/or description. Costs are USD decimal strings in lowest currency units (cents).

SELECT
ending_at,
results,
starting_at
FROM anthropic_admin.cost.cost_reports
WHERE starting_at = '{{ starting_at }}' -- required
AND ending_at = '{{ ending_at }}'
AND bucket_width = '{{ bucket_width }}'
AND "group_by[]" = '{{ group_by[] }}'
;