Skip to main content
Glama
io.github.ufhouck/aicost-cli

io.github.ufhouck/aicost-cli

calculate_ai_cost

Calculate exact AI API call costs from model, token usage, caching, batch discounts, and platform fees, with currency conversion for text and non-text models.

Instructions

Calculate the exact cost of an AI API call with full base cost, prompt-caching, batch discount, and aggregator platform fee breakdown. Supports 60+ curated models and 400+ live OpenRouter models.

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_id": "<model_id>"
    },
    "name": "calculate_ai_cost"
  }
}

Input Schema

NameRequiredDescriptionDefault
batchNoApply Batch API discount if supported (default: false)
unitsNoNumber of units for non-text models (images, seconds, minutes, songs, clips, 1M chars, or months)
currencyNoTarget currency code (default: 'USD')
model_idYesModel ID or alias (e.g., 'gpt-6.2-astra', 'claude-opus-5.5', 'gemini-4-carbon', 'grok-4.7', 'deepseek-v4.1-flash', 'veo-3.1')
input_tokensNoUncached input tokens (for text models)
output_tokensNoOutput completion tokens (for text models)
cached_input_tokensNoCached input tokens billed at cache-read rate

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.0

TDQS

B3.4/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the full behavioral burden. It does disclose meaningful scope information — the exact cost-component breakdown and the model coverage (60+ curated, 400+ live OpenRouter models) — but says nothing about whether pricing is live or cached, what happens for unsupported models, or whether the operation is read-only and side-effect free.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tight sentences with zero filler. The core action and its full cost breakdown are front-loaded, and model coverage follows as supporting scope information.

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 stateless calculator with a fully documented schema and no output schema, the definition covers what is computed and which models are supported; stating the breakdown implicitly describes the return content. Minor gaps remain around units/currency behavior for non-text models and pricing freshness, but nothing essential to a correct invocation is missing.

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 all seven parameters already carry their own documentation, including token fields, currency, batch, and units. The description's mention of caching and batch discounts loosely maps to those parameters but adds no format, constraint, or interaction detail beyond the schema, so the baseline of 3 applies.

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 verb and resource ("Calculate the exact cost of an AI API call") and enumerates the cost components included: base cost, prompt caching, batch discount, and aggregator platform fee. It does not distinguish itself from the closely named sibling get_ai_cost or from estimate_monthly_cost, so an agent cannot rule out overlap from the text alone.

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

Usage Guidelines2/5

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

There is no explicit when-to-use, when-not-to-use, or alternative-selection guidance, despite a sibling set that includes get_ai_cost, estimate_monthly_cost, and compare_ai_models. The phrase "AI API call" implies per-call costing rather than monthly projection, but the agent must infer that distinction rather than being told it.

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