How to use the AI token cost calculator
- Select a model from OpenAI, Anthropic, Google, DeepSeek, or Mistral.
- Enter expected input tokens (prompt + context) and output tokens (completion).
- Optionally set cached input tokens if your provider discounts prompt caching.
- Set number of requests (for example 1,000 chat turns or batch jobs).
- Read the total USD estimate, per-request cost, and the side-by-side model comparison.
What is an AI token?
Large language models do not bill by character or word. They bill by tokens — sub-word units produced by a tokenizer. In English, one token is often about 4 characters or roughly ¾ of a word, but code, non-English text, and punctuation can differ a lot.
API invoices almost always split input (everything you send) andoutput (everything the model generates). Output is usually priced higher because generation is more expensive to serve.
Token cost formula
For a single request without caching:
cost = (inputTokens / 1,000,000 × inputUSD) + (outputTokens / 1,000,000 × outputUSD)
With cached input tokens (when the provider supports a cache rate):
cost = ((input − cached) / 1M × inputUSD) + (cached / 1M × cachedUSD) + (output / 1M × outputUSD)
Multiply by the number of requests to project monthly or campaign spend.
Reference pricing table (USD per 1M tokens)
Snapshot used by this calculator for planning. Always verify on the provider’s official pricing page.
| Provider | Model | Input / 1M | Output / 1M | Cached in / 1M |
|---|---|---|---|---|
| OpenAI | GPT-4o | $2.5 | $10 | $1.25 |
| OpenAI | GPT-4o mini | $0.15 | $0.6 | $0.075 |
| OpenAI | GPT-4.1 | $2 | $8 | $0.5 |
| OpenAI | GPT-4.1 mini | $0.4 | $1.6 | $0.1 |
| OpenAI | o3 | $2 | $8 | $0.5 |
| OpenAI | o4-mini | $1.1 | $4.4 | $0.275 |
| Anthropic | Claude Sonnet 4 | $3 | $15 | $0.3 |
| Anthropic | Claude Opus 4 | $15 | $75 | $1.5 |
| Anthropic | Claude 3.5 Haiku | $0.8 | $4 | $0.08 |
| Gemini 2.5 Pro | $1.25 | $10 | $0.315 | |
| Gemini 2.5 Flash | $0.15 | $0.6 | $0.0375 | |
| Gemini 2.0 Flash | $0.1 | $0.4 | $0.025 | |
| DeepSeek | DeepSeek V3 | $0.27 | $1.1 | $0.07 |
| DeepSeek | DeepSeek R1 | $0.55 | $2.19 | $0.14 |
| Mistral | Mistral Large | $2 | $6 | — |
| Mistral | Mistral Small | $0.1 | $0.3 | — |
Example: 1,000 customer-support replies
Suppose each ticket uses about 1,500 input tokens and500 output tokens, and you process 1,000 requests.
- On a low-cost mini/flash model, total spend may stay well under a few dollars.
- On a flagship frontier model, the same volume can be tens or hundreds of dollars.
Use the comparison table above the fold to see the spread instantly before you lock architecture choices (which model, how much context, whether to enable prompt caching).
Tips to reduce LLM API cost
- Trim system prompts and retrieve only the context you need (RAG over huge dumps).
- Prefer smaller models for classification/routing; reserve large models for hard steps.
- Enable prompt caching when the same prefix is reused across calls.
- Cap
max_tokensso runaway completions cannot inflate output billing. - Log real token usage from the API and reconcile against this estimator weekly.
Why calculate token cost before shipping?
Token pricing looks tiny per call and expensive at product scale. A calculator turns vague “AI features” into a concrete unit economy: cost per chat, per document, per user, per month. That is essential for pricing your own SaaS, picking providers, and avoiding surprise invoices.