Skip to main content
Glama

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

NameRequiredDescriptionDefault
limitNo
sort_byNo
api_keysNo
end_dateNo
group_byYes
servicesNo
providersNo
sort_orderNo
start_dateNo
page_numberNo
pipeline_nameNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.1.40
    • addedInput schema / properties / api_keys
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Api Keys"
      +}
    • addedInput schema / properties / providers
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Providers"
      +}
    • addedInput schema / properties / services
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Services"
      +}
  2. Addedv0.1.31

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so thoroughly: it discloses USD units, default sorting, pagination via total/has_more/page_number, default 30-day range, null cost_total meaning, organization-admin permission needs, and the important warning not to add Service and pipeline groups together. It also explains that __unattributed__ appears for usage outside a Service and that results are stored in the object store for later inspection.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the purpose and organized into short paragraphs, and most content is necessary for an 11-parameter tool with no schema descriptions. It is still quite long, and the closing object-store/preview note plus some repeated Service-versus-pipeline explanation add bulk beyond the core call semantics.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 11 parameters, no annotations, no schema descriptions, and no output schema, the description is unusually complete: it covers permissions, scoping, grouping semantics, filtering behavior, pagination, return-preview/object-store handling, and edge cases like deleted pipelines and unpriced usage. The only notable inconsistency is the workspace reference not present in the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must document all 11 parameters, and it largely does: group_by values are explained, dates are inclusive/exclusive, sort fields and order are defined, services/providers/api_keys explain accepted ids versus names and filter combination semantics. The main flaw is that the prose refers to a workspace parameter ('Without workspace ... Use workspace') that is absent from the input schema, which could mislead an agent.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence states a specific verb and resource: it reads LLM cost for a workspace or pipeline, grouped by model, pipeline, Service, or API key. This is clear enough to understand the operation, but it never names sibling tools such as get_cost_totals or get_cost_over_time, so the distinction relies on the reader inferring that this is the grouped breakdown rather than a total or time series.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives useful usage context: use it to find what drove cost by model, pipeline, Service, or API key, and it explains organization-wide versus workspace scoping. However, it does not explicitly say when to choose this over get_cost_totals or get_cost_over_time, nor does it state exclusions beyond the Service/pipeline overlap warning.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools