Skip to main content
Glama

get_cost_totals

Retrieves total LLM costs, tokens, and requests for an organization, workspace, or pipeline over a date range, with filters for services, providers, models, and API keys.

Instructions

Reads the total LLM cost, tokens and requests of the workspace, or of one pipeline, over a date range.

Use this to answer how much a workspace or pipeline spent on LLM calls. Costs are in USD. Without dates the range is the last 30 days. start_date is inclusive and end_date exclusive, so for September 2026 pass 2026-09-01T00:00:00Z and 2026-10-01T00:00:00Z.

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 figures with services, providers, models and api_keys. They combine: usage must match every kind you set, and any one value within a list.

Check is_cost_complete before reporting total_cost. When it is false, total_cost is a lower bound, not the final figure: say so, and name the models in unpriced_models (LLM calls with no price on file) and mention pending_generation_count (calls whose cost is still being calculated, which usually clears within a minute). total_requests counts queries, not individual LLM calls; one query can make several LLM calls. :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 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: The cost totals, 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

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "get_cost_totals"
  }
}

Input Schema

NameRequiredDescriptionDefault
modelsNo
api_keysNo
end_dateNo
servicesNo
providersNo
start_dateNo
pipeline_nameNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.45
    • 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.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: it declares costs are USD, requires the organization admin role for the org-wide view, warns that pipeline_name and Service names are unusable in that view, and explains result reliability via is_cost_complete, unpriced_models and pending_generation_count. It also clarifies that total_requests counts queries rather than LLM calls, and describes the object-store preview/ID return behavior.

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?

Front-loaded with purpose, then scoping, then date rules, then filtering; each paragraph is doing work. The per-parameter ':param' block repeats details already stated in prose, and the trailing object-store boilerplate is generic filler.

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 seven-parameter read tool with no annotations and no output schema, the description covers purpose, defaults, permissions, filter combination logic ('usage must match every kind you set, and any one value within a list'), and how to interpret potentially incomplete totals. An agent could call this correctly without further information.

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 coverage is 0%, so the description must compensate, and it documents all seven parameters in depth: date semantics and defaults, the Services key/name-vs-id permission tradeoff, provider ids like bedrock_converse, exact model names, and that API keys are ids not secret tokens. It loses a point for referencing a 'workspace' argument in the prose that does not exist in the input schema.

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 first sentence gives a specific verb and resource ('Reads the total LLM cost, tokens and requests') plus the two scoping levels (workspace or one pipeline) and the date-range qualifier. It does not explicitly contrast itself with the sibling get_cost_breakdown or get_cost_over_time, so an agent must infer that 'totals' means aggregate rather than broken down.

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?

Strong context: 'Use this to answer how much a workspace or pipeline spent on LLM calls', explicit defaults (last 30 days, no upper bound), inclusive/exclusive date semantics with a worked example, and a clear rule for omitting workspace (org-wide view requires the organization admin role). The gap is that it never states when to prefer get_cost_breakdown or get_cost_over_time, so routing among the cost siblings is left implicit.

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