AI Context Window Budget Planner
A model can only read and write a limited number of tokens per request. Enter the context window, then how many tokens each part of your request uses and how many you want to keep free for the reply. The planner adds it up exactly and shows what remains, how full the window is and what to trim if it overflows.
Result
Enter a context window and your amounts to plan the budget.
- Input total
- Reserved for the reply
- Committed
- Remaining
- Window used
| Part | Tokens | Share of the window |
|---|
Examples
Worked examples with typical numbers (all values in tokens):
| Scenario | Window | Input | Reserved reply | Result |
|---|---|---|---|---|
| Chat assistant | 32,768 | 8,500 | 1,000 | Fits with room to spare (29%) |
| Document Q&A (retrieval) | 128,000 | 50,000 | 4,000 | Fits with room to spare (42.2%) |
| Agent with tools | 200,000 | 119,000 | 16,000 | Fits with room to spare (67.5%) |
| Long document in one request | 200,000 | 191,000 | 16,000 | Over the limit (−7,000) |
Formula & Methodology
The budget is plain addition, so the numbers are exact (given the amounts you enter):
input = system prompt + conversation + documents + toolscommitted = input + reserved replyremaining = context window − committedwindow used = committed ÷ context windowGood to know
- Most APIs count input and output together against the context window, but some models also cap the reply separately. Check your model’s documentation.
- “Tight” starts at 85% of the window, which leaves room for formatting overhead.
- Message wrappers, tool schemas, images and any reasoning tokens also use the window. Your own counts may miss them, so keep a margin.
- Context windows differ by model and change over time. This tool does not know your model: enter its window yourself.
- Words and characters are converted with editable averages. Use the token counter for a closer figure on real text.
Method and references
These primary sources support the methods this tool relies on. Having read them does not verify every result the calculator produces, and figures listed as assumptions are ToolQuarter’s own.
The planner’s arithmetic is exact. The sources support one idea: the window is shared by everything in the request and the reply, not only by your visible prompt.
- OpenAI API: Key concepts: States that for text generation models the prompt and the generated output combined must fit within the model’s maximum context length. ()
- Anthropic: Context windows: Defines the context window as all the text a model can reference when generating a response, including the response itself, and says tool definitions and thinking tokens count toward it. ()
- OpenAI API: Reasoning models: Notes that reasoning tokens are not visible in the API but occupy space in the context window, that you should leave room for them, and that window lengths differ across model snapshots. ()
ToolQuarter assumptions (no primary source):
- The 85% “tight” threshold is a ToolQuarter rule of thumb for leaving room for formatting overhead, not a provider limit.
- Words and characters are converted to tokens with editable averages that are ToolQuarter’s assumptions: use the token counter for real text. No model’s context window or output limit is built in, so enter your own.
How to Use
- Enter the context window of your model, or pick a common size.
- Choose whether you will type tokens, words or characters.
- Fill in each part of the request and the space to keep free for the reply.
- Read the remaining space and status, and trim the largest part if the plan is over.
Frequently Asked Questions
What is a context window?
It is the maximum number of tokens a model can handle in one request: your prompt, earlier messages, any documents and tools, and usually the reply as well. Anything beyond it is rejected or truncated, depending on the provider.
Do output tokens count against the context window?
In most APIs yes: input and output together must fit. Some models also set a separate maximum for the reply. That is why this planner reserves space for the reply instead of ignoring it.
How much should I reserve for the reply?
At least as much as the longest answer you expect, and not less than your maximum output setting if you set one. Reserving too little cuts answers off; reserving too much wastes space you could give to documents.
What happens when a request is over the window?
Depending on the provider you get an error, or older content is dropped or truncated. Neither is good for answer quality, so trim the largest part, summarise old messages or retrieve fewer passages.
How do I shrink a prompt that does not fit?
Summarise long conversation history, retrieve fewer or shorter passages, shorten tool definitions, trim the system prompt, or lower the reserved reply. The advice line points to the largest part first.
Last updated: