LLM tokens and cost

Chat conversation cost growth.

Chat APIs are stateless, so every turn resends the earlier messages. Enter a typical turn and see the total climb faster than the turn count.

Input tokens at turn t = system prompt + (t - 1) x (user + assistant tokens) + the new user message. A 30-turn chat with 150-token questions and 400-token answers, at example prices of $2.00 and $8.00 per 1M, costs $0.6135 in total. Turn 30 costs 8.1x turn 1. Keeping only the last 6 turns cuts the total to $0.3099.

Advertisement

Your numbers

Your numbers
Whole number from 1 to 1,000.
$
Example price. Replace with your provider's.
$
Example price. Replace with your provider's.
Leave blank to resend the whole conversation. Enter 6 to resend only the last 6 turns.

Result

Worked example

30 turns, a 500-token system prompt, 150 user tokens and 400 assistant tokens per turn, example prices of $2.00 and $8.00 per 1M. Turn 1 sends 500 + 150 = 650 tokens in and gets 400 out: (650 x 2 + 400 x 8) / 1,000,000 = $0.004500. Turn 30 resends 29 x 550 = 15,950 earlier tokens, so it sends 16,600 tokens in and costs $0.0364, which is 8.1x turn 1. The whole conversation costs $0.6135, and 92.5% of the input tokens are resent history. Resending only the last 6 turns brings the total to $0.3099. A single turn (turn 1 alone) costs $0.004500.

How it works

OpenAI's conversation state guide says that to share context across responses manually you include the model's previous output as input and append it to the next request. Everything in a request's input is billed as input tokens, so the earlier messages are billed again on every turn. Because each turn adds to the history, the input of turn t grows by one exchange per turn, so the total input over T turns grows with the square of T.

Windowing the history, summarising it, or caching the stable prefix all cut that growth; the prompt caching calculator shows the effect of the last. This model uses the same token count for every turn, resends whole turns and ignores system-added tokens and reasoning tokens.

Sources and basis (opened 2026-10-08): Conversation state | OpenAI API. Everything else is arithmetic on your inputs.

All prices on this page are examples you can overwrite, not any provider's current prices. Check your provider's pricing page before you rely on a number. Results are planning estimates, not a quote or financial advice. Everything runs in your browser. Nothing you type is sent or stored.

FAQ

Why do long chats get so expensive?

Each turn resends the earlier messages as input. In this example turn 30 costs 8.1x turn 1, and 92.5% of all input tokens are history that was already sent.

Is conversation cost really quadratic?

The input tokens summed over T turns grow roughly with T squared when the whole history is resent, because turn t carries t - 1 earlier exchanges. Output tokens only grow linearly.

How can I reduce the cost of long conversations?

Keep only recent turns, summarise old ones, or cache the stable prefix. Keeping the last 6 turns cuts this example from $0.6135 to $0.3099.

Does this include reasoning tokens or caching?

No. It assumes a constant number of tokens per turn at the standard prices you enter, with no caching.

Advertisement
Advertisement