Skip to main content
Glama

Claude API Pricing

Estimate Claude API cost

estimate_claude_cost
Read-only

Estimate the USD cost of Claude API calls from token counts. Handles prompt caching (cache writes and reads), the Batch API 50% discount and long-prompt pricing. Returns cost per request and in total.

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_claude_cost"
  }
}

Input Schema

NameRequiredDescriptionDefault
batchNoUse Batch API pricing (default false)
modelYesModel id, e.g. claude-fable-5-2, claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5
requestsNoNumber of requests (default 1)
input_tokensYesUncached input tokens per request
output_tokensYesOutput tokens per request (includes thinking tokens)
cache_read_tokensNoTokens read from the prompt cache per request
cache_write_1h_tokensNoTokens written to the 1-hour prompt cache per request
cache_write_5m_tokensNoTokens written to the 5-minute prompt cache per request

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so safety is covered; the description adds real value by disclosing which pricing regimes are handled (prompt caching writes and reads, Batch API 50% discount, long-prompt pricing) and that output is per-request plus total. It stops short of saying what happens with an unknown model id or how current the pricing table is.

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?

Three short sentences, front-loaded with the purpose and followed by the pricing features and return shape. Every sentence carries information; a minor deduction for the slightly list-like middle sentence rather than a tighter phrasing.

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 an 8-parameter, read-only calculator with no output schema, the description covers purpose, the pricing cases handled, and the return shape (per request and total), which is enough to call it correctly. What is missing is error/edge-case behavior for unsupported model ids, but that is a modest gap.

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 coverage is 100%, so every parameter is already documented in the input schema; the description only echoes cache writes/reads and the batch discount at a high level. It does not clarify the 1-hour vs 5-minute cache-write distinction or how 'requests' multiplies the per-request figures, so baseline 3 applies.

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?

Description names a specific verb and resource: 'Estimate the USD cost of Claude API calls from token counts.' That is clearly distinct from the sibling tools, which list and compare models, so an agent can route on purpose alone.

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 the 'from token counts' framing, but the description never states when to reach for this rather than compare_claude_models or list_claude_models, and it names no exclusions or prerequisites. The agent must infer that this is the cost-math tool.

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.