Skip to main content
Part ofCitedFigures.See the family
LLM Math Pro

LLM Cost Calculator

LLM API costs are denominated in tokens per million — a unit that obscures real-world economics. Enter your usage pattern (input tokens, output tokens, optional cached-input tokens, optional monthly request volume) plus the per-1M-token prices you pay, and this tool returns the exact cost per request, the monthly cost at your volume, a blended effective price per million tokens, and a per-component breakdown. Prices are always your inputs, never hardcoded: LLM pricing changes constantly, so the engine takes every rate as an argument and trusts you to verify it against the provider's published pricing page on the day you run the numbers. The math is plain arithmetic — cost = tokens ÷ 1,000,000 × price-per-million — open-source and independently verifiable, so the result is correct forever and only your inputs carry a date.

Example model presets

Presets fill the price fields only and are dated illustrations (as of June 2026), not live quotes — always verify the current per-million-token rate at the provider’s published pricing page before you trust a number.

Tokens per request
Prices ($ per 1M tokens) — your inputs

Enter the rates you actually pay, read from the provider’s pricing page today. The engine hardcodes no prices.

Optional: prompt caching
Optional: monthly volume
Cost per request
$0.0105
blended effective price $7.00 per 1M tokens
Monthly cost
$1,050.00

100,000 requests/month at this per-request cost

Per-component breakdown
ComponentTokens$/MCost
Input tokens1,000$3.00$0.003
Output tokens500$15.00$0.0075
Per request$0.0105

Prices shown are the ones you entered. Verify the current rate at the provider’s published pricing page.

View the TypeScript implementation on GitHub: packages/calc/src/llm-cost.ts · view tests

What this means

Token pricing hides the real economics of an LLM feature behind a per-million unit that feels abstract until the invoice arrives. The math itself is trivial — cost is tokens divided by a million, times the price per million — but the consequences compound fast across three components (input, output, cached) and then multiply by request volume. The whole point of this tool is to make that compounding visible before you build, not after.

In my experience the single biggest cost surprise is output tokens. Teams size their budget off the prompt — “our context is only 1,500 tokens” — and forget that a chatty model answering at 800 tokens, billed at five times the input rate, quietly becomes the dominant line item. I’ve seen a feature’s bill drop by more than half from a single change: capping max output tokens and prompting for terse answers. I’ve found that running the numbers here first, with realistic output lengths rather than optimistic ones, is the cheapest insurance against that surprise. If you are weighing models head to head, the blended effective price is the honest comparison; if you are choosing a tier for a task, start with the use-case picker and bring the result back here.

The deliberate design choice in this calculator is that prices are always your inputs. LLM pricing moves constantly, and any rate baked into the engine would silently rot and hand you a wrong answer months later. So the formula is timeless and only the inputs carry a date: read today’s rate off the provider’s pricing page, type it in, and the result is correct. The example presets exist only to save typing; the moment a provider changes a price, the preset is stale and the verification note is the part that matters.

Worked example

Take a chat feature that sends 1,000 input tokens (system prompt plus the user message) and generates 500 output tokens, using illustrative rates of $3/M input and $15/M output. Input cost is 1,000 ÷ 1,000,000 × $3 = $0.003. Output cost is 500 ÷ 1,000,000 × $15 = $0.0075. Per request that is $0.0105— and notice the output, at one-third the token count, costs two-and-a-half times as much as the input. At 100,000 requests/month the bill is 0.0105 × 100,000 = $1,050/month. The blended effective price is $0.0105 ÷ 1,500 tokens × 1,000,000 = $7.00 per 1M tokens.

Now add prompt caching. Suppose 10,000 tokens of that prompt are a stable, repeated prefix you can cache at a $0.30/M cache-readrate. Cached cost is 10,000 ÷ 1,000,000 × $0.30 = $0.003, so the per-request cost becomes $0.003 + $0.0075 + $0.003 = $0.0135. The cached 10,000 tokens cost the same $0.003 as 1,000 uncached tokens would have — a 10× discount on that portion — which is exactly why caching pays off when a large system prompt repeats across many calls. To model the savings in isolation, hand those numbers to the prompt caching savings calculator.

Frequently asked questions

See the methodology — how this tool is built, why prices are always user inputs (anti-staleness), and how it is reviewed. The cost math is open source and independently verifiable.

By Last verified against Provider published pricing pages (Anthropic, OpenAI, Google) — dated examples; prices are user-supplied

Founder & Editor, Bedrocka Tools

The information and tools on this website are for general educational purposes only and do not constitute financial, investment, legal, or tax advice. Consult a licensed professional for decisions specific to your situation.