Skip to main content
Glama

Estimate cost

estimate_cost
Read-onlyIdempotent

Calculate the cost of an LLM workload for a chosen model from official API prices, accounting for input, output, cached tokens, tiers, and long-context pricing.

Instructions

Cost of a workload on one model from official prices. input_tokens is the whole prompt per request; cached_input_tokens and cache_write_tokens are the parts of it read from / written to the prompt cache. The long-context band is chosen from the per-request token counts. Use tier for batch/flex/priority prices. When a model has several prices for the same request (thinking vs non-thinking, peak vs off-peak) every variant is returned with a range unless mode/time pins one down.

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": {
      "model": "<model>",
      "input_tokens": "<input_tokens>",
      "output_tokens": "<output_tokens>"
    },
    "name": "estimate_cost"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNo"thinking" or "non-thinking", for models priced by mode.
tierNostandard (default), batch, flex, priority or fast.
timeNoFor models with time-of-day prices.
modelYesModel id, alias, display name or "provider/id".
regionNoPrice region when the provider lists several, e.g. "intl". Default: the main region.
currencyNoAlso give the total converted to this currency (≈).
providerNo
requestsNoNumber of identical requests. Default 1.
input_tokensYesPrompt tokens per request, cached part included.
output_tokensYesOutput tokens per request (reasoning tokens included).
cache_write_ttlNoWhich cache-write price to use: short (default, e.g. 5 min) or long (e.g. 1 h).
cache_write_tokensNoPrompt tokens per request written to the cache.
cached_input_tokensNoPrompt tokens per request read from the cache (cache hits).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive and open-world, so safety is covered. The description adds real behavioral facts beyond them: that multiple price variants come back as a range unless mode/time pins one, and that the long-context band is selected from per-request token counts. Return-shape detail about the range object itself is still thin.

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 is front-loaded in the opening clause and each following sentence addresses a distinct invocation pitfall (cache token accounting, tier, variant ranges). It is dense with domain jargon and slightly telegraphic, but no sentence is wasted.

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

Completeness4/5

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

For a 13-parameter estimation tool with no output schema, the description covers the non-obvious mechanics: what token fields mean relative to each other, how pricing bands are chosen, and why a range may be returned. What is missing is a short statement of the returned figures' structure and whether currency conversion affects only the total.

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 92%, so the baseline is 3; the description earns above it by clarifying the relationship between input_tokens, cached_input_tokens and cache_write_tokens (the cache counts are subsets of the prompt, not additions), which prevents double counting. The long-context-band sentence also explains how a size threshold drives pricing rather than being a user parameter.

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 clause names a specific verb and resource: cost of a workload on one model from official prices. It clearly implies a per-workload computation rather than a per-token price lookup like get_model_price, but it never names a sibling to route against, so differentiation is left partly to inference.

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

Usage Guidelines3/5

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

It gives practical guidance for parameter choice (use tier for batch/flex/priority prices, use mode/time to pin a variant), which steers invocation. It offers no explicit statement of when to use this tool versus compare_models or get_model_price, so the when-to-use decision is only implied.

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