World of the Developers
All guides
AI

LLM Context Windows Explained: Why Long Conversations Get Expensive

October 5, 2026 · 5 min read

A model's context window is the maximum amount of text — measured in tokens — it can consider in a single request. Everything has to fit inside it: your instructions, any documents you attach, the conversation so far, and the answer the model is about to write. Understanding how that space gets used explains both why long chats hit limits and why they get costly.

What counts against the window

Four things share the same budget:

  • The system prompt and any standing instructions
  • Documents, search results, or other context you include
  • The full conversation history sent with each new message
  • The response itself — you need to leave room for the model's output

Why conversation costs grow faster than you expect

Chat APIs are stateless: to continue a conversation, you resend the earlier turns with every new message. So the input tokens on each turn include everything said so far.

Say each turn adds about 500 tokens. On turn 1 you send 500 tokens, on turn 2 about 1,000, on turn 10 about 5,000. Over a 20-turn conversation, the total input tokens you pay for is roughly 500 × (1 + 2 + … + 20) = 105,000 — more than ten times the 10,000 tokens of genuinely new content. Cost grows roughly with the square of the conversation length, not in a straight line.

What happens when you exceed the limit

Depending on the API, the request either fails outright or the oldest content is silently dropped to make room. Neither is good — a failed request breaks the user experience, and silently dropped history can make the model forget instructions or facts you were relying on without any visible error.

Bigger windows aren't automatically better

A larger window lets you fit more, but it doesn't guarantee the model uses everything equally well. Models can lose track of details buried in the middle of very long inputs, and a bigger window also means a bigger bill if you fill it. Match the window to what the task needs, not to the largest available.

How to stay under budget

The same few techniques cover most cases:

  • Summarize or drop older turns once they're no longer needed.
  • Retrieve only the relevant passages (retrieval-augmented generation) instead of pasting whole documents every turn.
  • Keep repeated content — system prompts, reference text — identical and at the start of the request so it can benefit from prompt caching where the provider offers it.
  • Cap the maximum response length so the output doesn't consume budget you didn't plan for.

Check how much of the window you're using

Our Context Window Calculator shows how much of a model's window your content uses, how much budget remains, and roughly how many more messages will fit — a useful check before you ship a feature that sends long histories.

Try the calculator

Context Window Calculator