How LLM API pricing works

How providers bill input vs output tokens, when cache, batch, and long-context tiers change the math, and how to estimate monthly spend before you ship.

Try it in TokenCALC

Open the cost calculator, pick a model, paste a real prompt, set output size and monthly volume, then compare.


You pay for tokens in and tokens out

Every major LLM API publishes separate USD prices per million input tokens and per million output tokens. Output is usually several times more expensive because generating text costs more compute than reading it. A short prompt with a long answer can dominate the bill even when the list price looks cheap.

The basic cost formula

Per request, cost is roughly (input_tokens × input_rate + output_tokens × output_rate) / 1,000,000. Monthly cost multiplies that by requests per day and days in the month. TokenCALC does this math from curated rates; always confirm critical budgets on the provider’s official pricing page.

  • Input tokens: system prompt, tools, history, user message, retrieved context
  • Output tokens: the model’s reply (and reasoning tokens when billed as output)
  • Never multiply word counts by a “price per million words”

Cache, batch, and long-context tiers

Prompt caching discounts repeated prefixes when the provider publishes a cached-input rate. Batch APIs often cut standard rates (commonly around half) in exchange for higher latency. Some models raise prices after a long-context threshold such as 200K tokens. TokenCALC only enables these controls when the catalog has published rates for that model.

Why list price shopping fails

Two models with similar input rates can differ wildly once you include output length, cache hit rate, batch eligibility, and tokenizer differences. Paste one representative workload, fix output size and volume, then compare. That is more honest than ranking by a single $/1M input number.

Exact counts vs Approx estimates

OpenAI encodings can be counted Exactly in the browser. Other providers are labeled Approx in TokenCALC when no official browser tokenizer is available. For Claude, use Anthropic’s count_tokens endpoint before production commits. For Gemini, use Google’s countTokens APIs. Pricing accuracy and count accuracy are separate problems; both matter.

Common pricing mistakes

These mistakes show up in early LLM budgets.

  • Ignoring output tokens
  • Budgeting from Word counts instead of tokens
  • Assuming every provider shares OpenAI’s tokenizer
  • Forgetting cache write costs when they are published
  • Treating curated calculator rates as a live streaming price feed

Best practices

Keep one golden prompt for comparisons. Project users times messages per day. Recheck forecasts against invoices. Use the cache savings and batch pricing tools when those levers apply, then confirm on the main cost calculator.

Real-world scenarios

A SaaS dashboard compares three vendors using only input list prices. The winning model generates longer JSON responses, erasing the input savings. Equal workload comparison in TokenCALC would have shown output driven COGS from the start.

An overnight ETL pipeline uses batch APIs while the interactive UI uses realtime endpoints. Finance needs two rate cards, not one blended average, because SLAs and discounts differ.

A research team runs million token contexts on a model with long context surcharges. The project fits technically but crosses a pricing tier that doubles effective input rates. Window fit and price fit must be checked together.

Step-by-step in TokenCALC

Paste a representative prompt on the cost calculator or tokenizer. Select model A and record input tokens, output assumption, and monthly volume.

Switch to model B without editing the prompt text. Compare total monthly projection, not isolated per million input numbers.

Toggle cache and batch controls when the catalog supports them for each model. Note lastVerified dates on rates before you share numbers externally.

Related concepts

Prompt cost focuses on single request math. Prompt caching and batch pricing tools isolate discounts. Context windows and long context tiers explain when input rate cliffs appear.

Provider bridge guides describe counting accuracy for OpenAI, Claude, and Gemini after you understand the pricing skeleton here.

Expert notes

Enterprise contracts may negotiate rates below public list. TokenCALC models public catalog numbers for planning, not your private amendment.

Tokenizer differences mean the cheaper model is not always cheaper for identical UTF-8 text. Cost comparison must hold text constant and compare both token counts and rates.

Observability stacks that log input and output tokens per feature make invoice reconciliation tractable. Align internal dashboards with the same definitions providers use in billing exports.

Warnings

Curated rates can lag official pages by days or weeks. Confirm before contractual commitments. Do not treat calculator output as a live price feed.

Hidden fees outside token billing (support tiers, dedicated capacity, data residency surcharges) are out of scope for token math but belong in total cost of ownership discussions.

Step-by-step comparison workflow

Save one golden prompt in your team wiki. Each month, paste it into TokenCALC on your current default model and on one challenger model. Record token counts, Exact or Approx labels, monthly projection, and lastVerified dates in the same table so finance can audit assumptions later.

When leadership asks for a three vendor snapshot, resist ranking by input list price alone. Export the monthly total from each row in the calculator after fixing output length and volume.


Frequently asked questions

How is LLM API cost calculated?

Multiply input and output tokens by each model’s per-million rates, then scale by request volume. Cache, batch, and long-context tiers can change the effective rate when published.

Why is output more expensive than input?

Generating tokens usually costs more compute than reading them. Providers publish higher output rates for that reason on most chat models.

Does prompt caching always save money?

Only when the same large prefix repeats often enough to beat any cache write cost and your hit rate is real. Measure with your prefix size and volume.

Are TokenCALC prices live?

No. Rates are curated from official docs and stamped with lastVerified dates. Confirm critical budgets on the provider page.

Should I compare models by list price alone?

No. Compare on the same pasted workload with realistic output size and monthly volume.

What is lastVerified on model rates?

The date TokenCALC last checked the provider pricing page for that row. Use it as a freshness signal, not a guarantee of same day accuracy.


Next steps

Use the calculator links above for Exact or Approx counts on your own prompts, then browse related guides and model pages to compare pricing assumptions.