Skip to main content
Glama

Estimate model cost

estimate_cost
Read-onlyIdempotent

What a model call costs per request, per day and per month at a given volume, from AI Gateway's live prices. Model ids look like 'openai/gpt-4.1-mini' or 'anthropic/claude-sonnet-4.5'.

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>",
      "requests_per_day": "<requests_per_day>"
    },
    "name": "estimate_cost"
  }
}

Input Schema

NameRequiredDescriptionDefault
modelYesA model id like 'openai/gpt-4.1-mini' or 'anthropic/claude-sonnet-4'
cached_shareNoShare of input tokens served from the prompt cache, 0 to 1
input_tokensYesInput tokens per request: system prompt, retrieved documents, history and the user's message
output_tokensYesOutput tokens per request: the length of a typical reply
requests_per_dayYesExpected requests per day, for the monthly cost

Output Schema

NameRequiredDescriptionDefault
modelYes
per_dayYes
per_monthYes
input_shareYesShare of the cost that's input tokens, 0 to 1
per_requestYes
price_sourceYes
prices_per_millionYesDollars per million tokens
cache_saving_per_monthYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • addedInput schema / properties / input_tokens / description
      Added value: +"Input tokens per request: system prompt, retrieved documents, history and the user's message"
    • addedInput schema / properties / model / description
      Added value: +"A model id like 'openai/gpt-4.1-mini' or 'anthropic/claude-sonnet-4'"
    • addedInput schema / properties / output_tokens / description
      Added value: +"Output tokens per request: the length of a typical reply"
    • addedInput schema / properties / requests_per_day / description
      Added value: +"Expected requests per day, for the monthly cost"
  2. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "https://json-schema.org/draft/2020-12/schema",
      +  "additionalProperties": false,
      +  "properties": {
      +    "cache_saving_per_month": {
      +      "type": "number"
      +    },
      +    "input_share": {
      +      "description": "Share of the cost that's input tokens, 0 to 1",
      +      "type": "number"
      +    },
      +    "model": {
      +      "type": "string"
      +    },
      +    "per_day": {
      +      "type": "number"
      +    },
      +    "per_month": {
      +      "type": "number"
      +    },
      +    "per_request": {
      +      "type": "number"
      +    },
      +    "price_source": {
      +      "enum": [
      +        "catalog",
      +        "fallback"
      +      ],
      +      "type": "string"
      +    },
      +    "prices_per_million": {
      +      "additionalProperties": false,
      +      "description": "Dollars per million tokens",
      +      "properties": {
      +        "cached_input": {
      +          "type": "number"
      +        },
      +        "input": {
      +          "type": "number"
      +        },
      +        "output": {
      +          "type": "number"
      +        }
      +      },
      +      "required": [
      +        "input",
      +        "cached_input",
      +        "output"
      +      ],
      +      "type": "object"
      +    }
      +  },
      +  "required": [
      +    "model",
      +    "per_request",
      +    "per_day",
      +    "per_month",
      +    "input_share",
      +    "cache_saving_per_month",
      +    "prices_per_million",
      +    "price_source"
      +  ],
      +  "type": "object"
      +}
  3. First observed

TDQS

A3.7/5.0
Behavior4/5

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

Annotations already cover the safety profile (readOnly, idempotent, openWorld, non-destructive), so the bar is lower. The description still adds genuine context by disclosing that prices are 'live' from AI Gateway, warning the agent that results are market-data dependent rather than fixed constants; it omits any note on invalid-model behavior or price staleness.

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?

Two compact sentences with the core computation front-loaded and the source qualifier attached; no filler. The second sentence largely restates the schema's model-id example, so it is slightly redundant but not costly.

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?

An output schema exists, so return values need no explanation; the description covers the unit of estimation, the aggregation windows, and the price source. It stops short of explaining how cached_share affects the estimate or what happens with an unknown model id, minor gaps for a read-only calculator.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all five parameters, including the model id format and token bounds. The description's model-id example duplicates the schema text verbatim rather than adding new meaning, so it earns only the baseline.

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 description names a specific computation (cost of a model call) and its three output granularities (per request, per day, per month) plus the price source (AI Gateway live prices). It is clearly distinct from siblings like count_tokens or compare_models, though it never explicitly names those alternatives.

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?

Usage is implied by 'at a given volume' – an agent can infer this is the tool for volume-based cost projection – but there is no explicit when-to-use/when-not guidance and no routing to price_ai_feature or compare_models, which are the nearest overlapping siblings.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources