Skip to content

LLM Token Cost, Context Window & Prompt Cache Calculator

Interactive pricing calculator comparing input context, output tokens, and prompt caching discounts across Claude 3.7, GPT-4o, Gemini 2.0, and DeepSeek.

By Gordon Geraghty·MIT Licence·Updated: 21 August 2026·INTERMEDIATE·GitHub Mirror ↗

LLM Token Cost, Context Window & Cache Efficiency Calculator

Live Client-Side Pricing Engine

Compare API costs and prompt caching savings across Claude 3.7, GPT-4o, Gemini 2.0 and DeepSeek. Enter your average context size, completion tokens and monthly request volume below.

Model Selection & Token Parameters

18,750 cached tokens billed at read discount

Cost Breakdown & Caching Efficiency

Cost per Request
$0.046875
$0.024375 in + $0.0225 out
Monthly Spend
$468.75
10,000 monthly calls
Cache Savings
$506.25
51.92% lower than base cost
Uncached Monthly Cost
$975
Without prompt caching
Multi-Model Cost Comparison (Identical Workload)
ModelPer CallMonthlySavings
Claude 3.7 Sonnet (Selected)$0.046875$468.75+$506.25
Claude 3.5 Sonnet $0.046875$468.75+$506.25
Claude 3.5 Haiku $0.0125$125+$135
GPT-4o $0.054062$540.63+$234.38
GPT-4o mini $0.003244$32.44+$14.06
Gemini 2.0 Flash $0.001694$16.94+$14.06
Gemini 1.5 Pro $0.021172$211.72+$175.78
DeepSeek V3 $0.001558$15.58+$23.63
DeepSeek R1 $0.009348$93.48+$76.88
Built by Gordon Geraghty, Head of PerformanceZero Data Sent to Server

How Prompt Caching Cuts LLM Application Costs

Modern frontier models support prompt caching on static system instructions and retrieval context. Anthropic offers up to a 90% discount on cached reads, while Google and OpenAI offer substantial discounts on repeated context. For applications with large system prompts, caching reduces operational spend significantly.

Implementation Code & Script

Prompt Caching Cost Enginellm-caching-cost.tstypescript

Calculates blended input token costs considering cached read rates versus full write rates.

export function calculateBlendedInputCost(
  tokens: number,
  cacheHitRatio: number,
  baseRatePerMillion: number,
  cacheReadRatePerMillion: number
): number {
  const uncachedCost = (tokens * (1 - cacheHitRatio) * baseRatePerMillion) / 1_000_000;
  const cachedCost = (tokens * cacheHitRatio * cacheReadRatePerMillion) / 1_000_000;
  return Number((uncachedCost + cachedCost).toFixed(6));
}

How to cite and attribute this tool

MIT Licence

This resource is free, open and un-gated under the MIT Open Source Licence. You are encouraged to use, integrate and cite it with attribution:

Geraghty, G. (2026). LLM Token Cost, Context Window & Prompt Cache Calculator. Gordon Geraghty Resources Hub. https://gordongeraghty.com/resources/ai-engineering/llm-token-cost-calculator
BibTeX Format
@misc{geraghty_llm_token_cost_calculator,
  author = {Geraghty, Gordon},
  title = {LLM Token Cost, Context Window & Prompt Cache Calculator},
  year = {2026},
  url = {https://gordongeraghty.com/resources/ai-engineering/llm-token-cost-calculator},
  note = {Head of Performance, Empire Amplify}
}

Changelog & Version History

  • v1.0.0Initial release with multi-model prompt caching pricing engine.