How to Estimate LLM API Costs

The formula

Monthly cost

monthly cost = requests × (input_tokens × input_price + output_tokens × output_price) ÷ 1,000,000

Example: 100K requests/month at 2,000 input + 500 output tokens on a $2.50/$15 model

100,000 × (2,000 × $2.50 + 500 × $15) ÷ 1M

= 100,000 × ($0.005 + $0.0075)

$1,250/month

The four corrections that make estimates real

  1. Tokenize your actual payloads. English ≈ 4 chars/token is a rough floor; code, JSON and non-English run heavier. And tokenizers differ by family — Anthropic's newest models produce ~30% more tokens for identical text than older Claude models.
  2. Count the invisible tokens. System prompts, tool definitions (hundreds of tokens each), retrieved context and conversation history all bill as input on every request.
  3. Model caching. If most requests share a large prefix (agents, chatbots with long system prompts), cache reads at ~0.1× input price change the math by an order of magnitude.
  4. Check the deprecation calendar. A model retiring mid-quarter (see the tracker — six OpenAI shutdown waves are scheduled for H2 2026) forces a migration whose replacement may price differently — or, like Sonnet 5 on Sept 1, the same model simply gets +50% dearer.

Run your numbers in the calculator — it uses only provider-verified prices.