How to plan a context window
- Choose your model's context window, from 8K tokens for small local models to 1 million or more for long-context models.
- Enter how many tokens each part of the request uses: system prompt, tool definitions, retrieved documents, chat history, the user's message, and the space you reserve for the reply. Paste text into "Estimate tokens from text" if you do not know a number.
- The bar shows how full the window is, how many tokens are left, and roughly how many more pages of documents or chat turns would fit.
Why budgeting context matters
A model's context window covers everything in one request: instructions, examples, tools, documents, the whole conversation so far and the answer it writes. If the total is too large, the API rejects the request or older messages are cut off, often silently, so the assistant "forgets" earlier instructions. Reserving space for the reply is easy to forget: if you fill a 128K window with documents, there is no room left for a long answer, and reasoning models also need space for their hidden thinking tokens.
Bigger is not always better. Every token costs money and adds latency, and models are often less accurate at finding details in the middle of a very long context. Good practice is to retrieve only the most relevant chunks, summarise old chat turns, keep tool definitions lean and leave a safety margin, since token counts vary between tokenizers. The page assumes about 500 tokens per page of text and 350 per chat turn, which are typical for English. Everything is calculated locally.
Does the output count towards the context window?
Yes. Input plus output must fit in the window, and many APIs also have a separate maximum output limit.
How many pages fit in 128K tokens?
Roughly 250 pages of plain English text, before system prompts, history and reply space.
What happens when a chat exceeds the window?
Apps usually drop or summarise the oldest messages. Raw APIs return an error, so you must trim the input yourself.