get_cost_breakdown
Break down LLM costs by model, pipeline, Service, or API key to see what drove spending, with filters, sorting, date ranges, and paginated results.
Instructions
Reads the LLM cost of the workspace, or of one pipeline, grouped by model, pipeline, Service or API key.
Use this to find what drove the cost: which models, pipelines, Services or API keys spent the most.
Costs are in USD. Results are sorted by cost, highest first, unless you set sort_by and sort_order.
Each entry has a key (a model or provider name, or a UUID for the other dimensions) and a readable
label. A deleted pipeline still shows up with group_by='pipeline', labelled with its UUID.
total is the number of groups across all pages; when has_more is true, read the next
page_number. total_requests counts queries, not individual LLM calls. A cost_total of null
means the group had usage but none of it was priced. Without dates the range is the last 30 days.
A Service (group_by='deployment') is a published Service endpoint; a deployed pipeline is a pipeline
(group_by='pipeline'). The two overlap: a query through a Service that runs a pipeline counts in both,
so never add Service groups and pipeline groups together. Usage that did not go through a Service shows up
as __unattributed__ under group_by='deployment'.
Without workspace the figures cover the whole organization, as the Cost Management page does for an
organization admin; this needs the organization admin role. Use workspace for one workspace. In that
organization view pipeline_name and Service names can't be used (they belong to a workspace); pass
Service ids instead.
Narrow the breakdown with services, providers and api_keys, for example the models of one
Service. They combine: usage must match every kind you set, and any one value within a list.
:param group_by: The dimension to group by: model, workspace, pipeline, deployment (a Service), api_key or
provider.
:param pipeline_name: Restrict to this pipeline. Omit for the whole workspace. Needs Pipelines read as well as
Costs read.
:param start_date: Inclusive start as an ISO timestamp. Defaults to 30 days before end_date.
:param end_date: Exclusive end as an ISO timestamp. Defaults to no upper bound.
:param sort_by: Sort by label, cost_total, total_tokens or total_requests. Defaults to cost_total.
:param sort_order: ASC or DESC. Defaults to DESC.
:param limit: Groups per page, from 1 to 100.
:param page_number: The page to read, starting at 1.
:param services: Restrict to these Services (deployment in the API; a published Service endpoint, not a
deployed pipeline, which is a pipeline). Each value is a Service name or its id, the key from
get_cost_breakdown with group_by='deployment'. Looking a Service up by name needs Services read as
well as Costs read; an id needs only Costs read.
:param providers: Restrict to these providers. Use the provider ids from get_cost_breakdown with
group_by='provider', such as bedrock_converse or openai, not their display names.
:param api_keys: Restrict to these API keys. Use the key ids from get_cost_breakdown with
group_by='api_key', never a key's secret token.
:returns: One page of the breakdown, or an error message.
The output is automatically stored and can be referenced in other functions.
Returns a formatted preview with an object ID (e.g., @obj_123).
Use the object store tools in combination with the object ID to view nested properties of the object.
Use the returned object ID to pass this result to other functions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| sort_by | No | ||
| api_keys | No | ||
| end_date | No | ||
| group_by | Yes | ||
| services | No | ||
| providers | No | ||
| sort_order | No | ||
| start_date | No | ||
| page_number | No | ||
| pipeline_name | No |