induwara.lk
induwara.lkDevelopers · AI cost

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.

By Induwara AshinsanaUpdated Jul 11, 2026
Conversation cost
Full-history model · verified

OpenAI · $2.5 in / $10 out per 1M tokens.

turns

One user message + one assistant reply per turn.

Resent on every turn.

Average length of each user message.

Average length of each assistant reply.

Think in words? Multiply words by ~1.33 to estimate tokens — or use the tokens ↔ words converter.

Turns
Total cost
$0.0825
Total input tokens
21,000
Grows quadratically with turns
Total output tokens
3,000
Linear: turns × reply size
vs naive estimate
2.2×
Actual ÷ first-guess cost

The gotcha

Naive guess
$0.0375
No history resent
Actual cost
$0.0825
Full history resent
Multiplier
2.20×
your first guess

At this rate, a 100-turn thread would cost $5.325 with these same per-turn sizes.

Cumulative cost curve

Running total across 10 turns — note how the slope steepens: each turn resends a longer transcript than the last.

Turn 1Turn 10 · $0.0825

Per-turn breakdown

TurnInput tokensOutput tokensTurn costRunning total
1300300$0.0037$0.0037
2700300$0.0048$0.0085
31,100300$0.0058$0.0142
41,500300$0.0067$0.021
51,900300$0.0078$0.0287
62,300300$0.0087$0.0375
72,700300$0.0098$0.0473
83,100300$0.0108$0.058
93,500300$0.0118$0.0697
103,900300$0.0128$0.0825

Sources: pricing from OpenAI, Anthropic and Google. The stateless full-history mechanism is documented in the OpenAI conversation-state guide. Rates are a snapshot — override any model with custom rates above.

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

GPT-4o · short support chat (10 turns)

P_in $2.50/1M · P_out $10/1M · S=200, U=100, A=300

  1. Total input = 10·(200+100) + (100+300)·10·9/2
  2. = 3,000 + 400·45 = 3,000 + 18,000 = 21,000 tokens
  3. Total output = 10·300 = 3,000 tokens
  4. Cost = 21,000/1e6·2.50 + 3,000/1e6·10 = $0.0525 + $0.0300 = $0.0825
  5. Naive = 10·300/1e6·2.50 + 3,000/1e6·10 = $0.0075 + $0.03 = $0.0375
  6. → Actual is 2.2× the naive guess.

Claude Sonnet 4 · long agent thread (30 turns)

P_in $3/1M · P_out $15/1M · S=500, U=150, A=400

  1. Total input = 30·(500+150) + (150+400)·30·29/2
  2. = 19,500 + 550·435 = 19,500 + 239,250 = 258,750 tokens
  3. Total output = 30·400 = 12,000 tokens
  4. Cost = 258,750/1e6·3 + 12,000/1e6·15 = $0.77625 + $0.18000 = $0.9563
  5. Naive = 30·650/1e6·3 + 12,000/1e6·15 = $0.0585 + $0.18 = $0.2385
  6. → Actual is 4.0× the naive guess — the longer the thread, the wider the gap.

GPT-4o · runaway thread (edge case, 500 turns)

P_in $2.50/1M · P_out $10/1M · S=200, U=100, A=300

  1. Total input = 500·300 + 400·500·499/2
  2. = 150,000 + 49,900,000 = 50,050,000 tokens
  3. Total output = 500·300 = 150,000 tokens
  4. Cost = 50.05M/1e6·2.50 + 0.15M/1e6·10 = $125.125 + $1.50 = $126.625
  5. Naive = 500·300/1e6·2.50 + 150,000/1e6·10 = $0.375 + $1.50 = $1.875
  6. → Actual is 67.5× the naive guess. This is why unbounded chat memory bankrupts a flat quote.

Frequently asked questions

Sources & references

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

Rate this tool
Be the first to rate

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.