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.
LLM Token Cost, Context Window & Cache Efficiency Calculator
Live Client-Side Pricing EngineCompare 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
Cost Breakdown & Caching Efficiency
Multi-Model Cost Comparison (Identical Workload)
| Model | Per Call | Monthly | Savings |
|---|---|---|---|
| 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 |
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
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 LicenceThis resource is free, open and un-gated under the MIT Open Source Licence. You are encouraged to use, integrate and cite it with attribution:
@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.