AI Conversation Cost Calculator
Estimate what a multi-turn LLM chat really costs. Because the API resends the whole conversation history on every turn, a long thread costs far more than reply-tokens × turns — this tool shows the actual figure, the per-turn climb, and how badly the naive guess undershoots.
How it works
Chat APIs from OpenAI, Anthropic, and Google are stateless: the server keeps no memory of your conversation between requests. To give the model context, your client resends the system prompt, every prior user and assistant message, and the new user message on everyturn. You are billed for all of those input tokens each time. (See OpenAI's “Managing conversation state” guide and Anthropic's Messages API reference, both linked below.)
Let S be the system prompt tokens, U the average user-message tokens, A the average assistant-reply tokens, and T the number of turns. On turn i (counting from 1) the billed input is:
input(i) = S + U + (i − 1)·(U + A)
The (i − 1)·(U + A) term is the growing transcript — every earlier user/assistant pair, re-sent. Summing over all turns gives the totals:
- Total input = T·(S + U) + (U + A)·T·(T − 1)/2
- Total output = T · A
- Cost (USD) = Total-input/1e6 · Pin + Total-output/1e6 · Pout
The input total has a quadratic term in T, which is why cost accelerates as a chat gets longer. To keep the math honest the tool computes this closed form and cross-checks it against a direct turn-by-turn summation — both must agree to the token before any result is shown.
The naive estimate most developers make ignores history: every turn is assumed to send only S + U input and A output, giving a cost that is only linear in T. The calculator prints the ratio of actual to naive so you can see the gap — often 2× on a short chat and 10×+ on a long one. Prices come from each provider's official pricing page and are a dated snapshot; the core math is rate-independent, so a custom rate override keeps the tool accurate even after a vendor reprices.
Worked examples
Frequently asked questions
Sources & references
- OpenAI — Managing conversation state (API is stateless; full history resent)
- Anthropic — Messages API reference (the messages array is the full history)
- OpenAI — API pricing (per-1M input/output token prices)
- Anthropic — API pricing (Claude rates + prompt-caching multipliers)
- Google — Gemini API pricing
Model prices were last cross-checked against these pages on 2026-07-11. The conversation math (quadratic input growth) is rate-independent and does not change when vendors reprice. If you spot a stale rate, use the custom-rate override in the calculator and email me so I can update the snapshot.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.