- Set the workload
Enter model context window and any other volume assumptions that define the period or batch.
- Add usage assumptions
Complete the remaining usage fields, keeping token, duration, or size units consistent with their labels.
- Enter current rates
Use the current prices for the exact model, endpoint, quality, and processing tier you plan to use.
- Review the estimate
Read the main result and the supporting breakdown to see the largest cost or capacity driver.
- Test another scenario
Change one assumption at a time or select Reset to restore the default example values.
OpenAI Context Calculator
The OpenAI Context Calculator checks whether a planned request fits within a model context window. It adds every input component and the reserved output allowance, then reports remaining capacity and utilization.
Use it before deploying long prompts, document analysis, conversation memory, or retrieval-augmented generation. The calculation helps prevent context overflow and makes tradeoffs visible when instructions, history, attachments, and output all compete for the same window.
Calculation inputs
The calculator applies the entered values directly and displays rounded results for planning.
What the result means
A nonnegative result indicates that the planned request fits within the entered context window.
Providers may enforce separate maximum output limits even when the combined request fits the context window.
Given: Example assumptions
Calculation: For a 128,000-token window with 1,200 system, 12,000 history, 50,000 documents, 800 user, 4,000 reserved output, and 2,000 buffer tokens, planned usage is 70,000 tokens. Remaining capacity is 128,000 − 70,000 = 58,000 tokens, or 54.7% utilization.
Result: The displayed result follows the same formula and rounding logic.
Does the output reserve count toward the context window?
Yes. Input and generated output generally share the available context budget, so leave room for the desired response.
Why include a safety buffer?
Token estimates can be imperfect and wrappers may add instructions. A buffer reduces the chance of exceeding the limit.
Should tool results be included?
Include any tool result text that is sent back to the model within the same request or conversation turn.
What happens when the total is too large?
The request may be rejected or content may need truncation, summarization, chunking, or selective retrieval.
Is a larger context always better?
Not necessarily. Larger inputs can cost more and may dilute relevant information, so include only material that helps the task.