AI token calculator: what a prompt actually costs
Token counting tools tell you how many tokens a prompt uses. They do not tell you what it costs, because cost depends on three more things: the output rate, the cache behaviour, and which supplier served the request.
Here is the whole calculation, with the numbers you need to fill in.
The formula
cost = (input_tokens × price_in + output_tokens × price_out) / 1,000,000
Prices are per 1M tokens, quoted separately for input and output. Cached input is billed at a reduced rate, usually 10–25% of the input rate.
Worked example — a support reply on a mid-tier model at market rates ($0.20 in / $2.00 out per 1M), 900 input tokens, 250 output:
(900 × 0.20 + 250 × 2.00) / 1,000,000
= (180 + 500) / 1,000,000
= $0.00068 per request
At 40,000 requests per day: $27.20/day, about $816/month.
Run the same prompt on a frontier model ($0.50 in / $2.50 out): $1.1e-3 per request → $44/day. A flash tier ($0.03 / $1.50): $2.07/day.
Same prompt, three answers, 20× spread. The model choice is the calculator.
The three inputs people get wrong
1. Output tokens
Most cost estimates count input and ignore that a chatty model writes 400 tokens where a terse one writes 180. Output is priced 2–5× input, so verbosity is the dominant variable in conversational products.
Rule of thumb: for a chat turn, assume output ≈ 30–40% of input tokens, then verify on your own logs. For extraction and classification, output is near-constant and small — those workloads are input-bound.
2. System prompt re-payment
Every request re-pays for the system prompt unless it is cached. A 600-token system message in a 900-token prompt is two thirds of your input bill, spent on the same bytes 40,000 times a day.
600 tokens × 40,000 requests × $0.20/1M = $4.80/day
with caching at 10% of the rate: $0.48/day. Small per call, real per month.
3. Retries and re-runs
A retry after the first streamed token is a second full charge. A re-run on a bigger model after a small model fails is a full charge too. Effective cost is:
effective = sticker_cost × (1 + retry_rate + escalation_rate)
At 5% retries and 8% escalation, that is a 13% surcharge that never appears on a price page.
Token counts, roughly
Exact counts depend on the tokenizer, but these hold well enough for estimates:
| Content | Tokens (approx.) |
|---|---|
| 1 word of English | 1.3 |
| 1 page of text (500 words) | ~650 |
| 1,000 characters | ~250 |
| 1 line of code | ~10–15 |
| 1 hour of transcript | ~9,000 |
So 1M tokens ≈ 750,000 words ≈ 1,500 pages. That is the scale behind "100M free tokens" offers: enough to read roughly 150,000 pages.
Worked examples by workload
Chat with a 600-token system prompt, 300-token conversations, 12 turns:
Per turn ≈ 300 in + 250 out → at $0.20/$2.00 that is $0.00056, and a 12-turn session re-pays the system prompt 12 times → about $0.0075 per session.
RAG over a document set, 5 chunks × 400 tokens retrieved:
2,000 retrieved tokens + 200 question + 300 output ≈ $0.001 per query at mid-tier rates. The retrieval quality decides whether you can afford five chunks or need twenty.
Agent loop, 8 tool calls:
Each step re-sends accumulated history. A naive implementation grows input quadratically: step 8 might send 6,000 tokens of history for a 200-token action. Trim history and summarise mid-loop — this is where agent bills explode.
A spreadsheet that stays honest
| Column | Why |
|---|---|
| task class | routing unit |
| model | the string you actually pass |
| p50 input / output tokens | median, from logs |
| p95 input / output tokens | tail, drives capacity |
| effective unit price | from your own bill, not the rate card |
| retries per 100 | the invisible surcharge |
Multiply by monthly volume. Anything you cannot fill in is a guess, and guesses are where budgets die.
Where these numbers come from
Rates used in the worked examples are live offers from the Cisoma pricing table, quoted per 1M input and output tokens; the model pages carry the per-model figures, and the ranking page shows which models carry the most traffic. Tokenizer behaviour differs per vendor — OpenAI's tokenizer documentation and Anthropic's token counting guide are the references.
The optimisation sequence that follows from this arithmetic is in how to reduce LLM costs, with the deeper accounting in the complete guide to AI token counting.
Run the numbers for your own prompts in the LLM API cost calculator and the token counter.
FAQ
How do I calculate tokens for a prompt?
With the provider's tokenizer — tiktoken for OpenAI-family models, the vendor's own counter elsewhere. For planning, 1 token ≈ 0.75 English words is accurate enough; for billing reconciliation, use the tokenizer and the provider's reported usage.
How much does 1,000 tokens cost?
Depends entirely on the model. At market rates, 1,000 input tokens costs from $0.0000056 (deepseek-flash) to $0.0006 (gemini-3.1-pro, claude-opus-5 tier). That is a 100× spread for the same quantity.
Does input or output cost more?
Output, by 2–5×, on every vendor. A model that answers in half the tokens can be cheaper than one with half the input rate.
Why is my bill higher than the calculator says?
Three usual causes: retries after partial streaming, uncached system prompts, and context growth in agent loops. Compare billed input tokens against the tokens you intended to send — the ratio is your waste.
Is there a free way to estimate cost before signing up?
Yes: count tokens locally with the model's tokenizer, multiply by published per-1M rates, and add your expected retry rate. Compare that figure against live marketplace rates before committing to a vendor.
Every number on this page comes from the marketplace's own live offers. Point the OpenAI SDK at Cisoma and keep your code.
Get 100M free tokens