Skip to main content
Glama

get_cost_breakdown

Breaks down LLM costs by model, pipeline, service, API key, component, or user, with filters and date ranges, to reveal what drove workspace or pipeline spending.

Instructions

Reads the LLM cost of the workspace, or of one pipeline, grouped by a dimension such as model or pipeline.

Use this to find what drove the cost: which models, pipelines, Services, API keys, components or users 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, provider or component 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, models 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, provider, component (the pipeline component that made the LLM call) or user (labelled with the user's name or email). :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 models: Restrict to these models. Use the model names from get_cost_breakdown with group_by='model', exactly as returned. :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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "group_by": "<group_by>"
    },
    "name": "get_cost_breakdown"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
modelsNo
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. Changed2 schema fields changedv0.1.45
    • changedInput schema / properties / group_by / enum
      Previous value: -[
      -  "model",
      -  "workspace",
      -  "pipeline",
      -  "deployment",
      -  "api_key",
      -  "provider"
      -]New value: +[
      +  "model",
      +  "workspace",
      +  "pipeline",
      +  "deployment",
      +  "api_key",
      +  "provider",
      +  "component",
      +  "user"
      +]
    • addedInput schema / properties / models
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Models"
      +}
  2. 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"
      +}
  3. Addedv0.1.31

TDQS

A4.9/5.0
Behavior5/5

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

No annotations exist, so the description carries the full burden, and it does: default 30-day window, exclusive end date, sort defaults, pagination semantics ('total is the number of groups across all pages'), the meaning of a null cost_total, that deleted pipelines still appear, __unattributed__ usage, the Service/pipeline overlap double-counting trap, and the permission requirement for org-wide figures. It also discloses that results are stored in the object store and returned as a preview with an object ID.

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?

Purpose and the highest-risk caveats (Service vs pipeline double counting, org-role requirement) are front-loaded before the parameter list, which is the right order. It is dense but mostly earns its length; some redundancy exists, e.g. the Service/'deployment' definition is stated twice, once in the body and again inside the services parameter description.

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?

For a 12-parameter, unannotated, no-output-schema tool this is thorough: return fields (key, label, total, has_more, total_requests, cost_total nullability), defaults, filtering semantics, permissions, and the object-store handoff are all covered. An agent has everything needed to call it and interpret the result.

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

Parameters5/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 compensate, and every one of the 12 parameters is documented in the ':param' block. It adds meaning beyond the raw schema: group_by enum values are explained in plain terms, providers must be ids not display names, models must match exactly as returned, api_keys require key ids 'never a key's secret token', and services accepts a name or id with differing read-permission costs.

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

Purpose5/5

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

Opens with a specific verb and resource plus scope: 'Reads the LLM cost of the workspace, or of one pipeline, grouped by a dimension such as model or pipeline.' The second sentence ('find what drove the cost: which models, pipelines, Services, API keys, components or users spent the most') distinguishes it implicitly from aggregation siblings like get_cost_totals and get_cost_over_time without needing to name them.

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

Usage Guidelines5/5

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

Gives explicit usage context (find cost drivers), explicit exclusions and reader warnings (never add Service groups and pipeline groups together; organization view can't use pipeline_name or Service names). It also states the prerequisite role for the organization-scoped view and explains how the filter parameters compose.

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