← All guides

How to Estimate LLM API Costs Before You Build

Published 2026-06-25 · 6 min read

Most teams discover their LLM bill is too high after shipping. It does not have to be a surprise — token pricing is simple arithmetic once you know the three inputs that drive it.

The only formula you need

Every token-based API charges separately for what you send and what you get back:

cost per request = (input_tokens × input_price + output_tokens × output_price) / 1,000,000

Multiply by your monthly request count and you have your bill. A token is roughly ¾ of an English word, so 1,000 tokens ≈ 750 words.

A worked example

Say you run a support assistant: a 1,500-token system prompt + context, a 300-token user question, and a 400-token answer, 200,000 times a month. That is 1,800 input and 400 output tokens per call.

  • GPT-5.4 ($2.50 in / $15 out): (1,800×2.5 + 400×15) / 1e6 = $0.0105/call → ~$2,100/mo.
  • GPT-5.4 nano ($0.20 / $1.25): ~$172/mo.
  • Gemini 2.0 Flash ($0.10 / $0.40): ~$68/mo.

Same workload, a 30× spread. That is why picking the right tier matters more than almost any other optimisation. Run your own numbers in the cost calculator.

The levers that actually move the bill

  • Output length. Output is 2–5× the input price almost everywhere. A tight max_tokens is the single biggest control you have.
  • Prompt caching. If you resend the same instructions or document every call, caching can cut that input cost by 75–90% (Anthropic, OpenAI and DeepSeek all offer it).
  • Model routing. Send easy requests to a cheap model and only escalate the hard ones. Most traffic does not need a flagship.
  • Batch API. For non-urgent jobs, batch endpoints are typically ~50% cheaper.

Don't optimise for sticker price alone

A cheaper model that fails and forces a retry — or a human escalation — can cost more than a pricier model that gets it right first time. Track cost per successful outcome, not cost per token.

Ready to compare? See the full LLM API price table or the cheapest LLM APIs.

Compare every model's price in the live pricing table, or estimate your own bill with the cost calculator.