Skip to content

Context window: what fits, what it costs, when bigger hurts

A context window is the token limit one model call shares between input and output. What fills it, window sizes, what long inputs cost, and where quality falls.

Published
Reading time
11 min read

In short

  • A context window is the most tokens one model call can hold, and input and output share it. Everything you send, the model's reasoning, and its answer all count against the same limit.
  • In a real request the user's message is usually the smallest part. Tool definitions, the system prompt, conversation history, retrieved documents, and the output reserve fill most of the window.
  • As of November 23, 2026, current Claude, GPT-6.2, and Gemini 4 models all list windows of about one million tokens, with 64K to 128K of output per synchronous call.
  • Long inputs cost more than their token count suggests. OpenAI doubles the input rate for the whole request above 272K input tokens, Claude Haiku 5.5 charges five times as much above 100K, and every uncached token adds to time to first token.
  • A model's accuracy falls well before the window is full, so treat the window as a ceiling and size requests by what the task needs.

A context window is the maximum number of tokens a language model can handle in one call, and the input and the output share it. The system prompt, tool definitions, every earlier message, any documents, the model's reasoning, and the answer it writes all count against the same limit. The window sets what fits. It says nothing about what the model will use well, and every token in it is billed and read on each call.

This article covers what fills a context window in a production request, how large current windows are, what long inputs cost in money and latency, and why a bigger window can make answers worse.

What a context window is

A context window is the token budget for a single request: input tokens plus output tokens, including reasoning tokens on models that think before answering. Anthropic's context window docs define it as all the text a model can reference when generating a response, including the response itself. OpenAI's conversation state guide says the same: the limit covers input, output, and reasoning tokens.

Three consequences follow.

  • The window is per call, not per conversation. A chat API keeps no memory between calls. Each turn resends the history, so a conversation's context grows until it reaches the limit.
  • Output takes room from input. Reserving 128K tokens for output on a 1.05M window leaves 922K for input. OpenAI lists exactly that split for GPT-6.2 Sol: a 1,050,000-token window, a 922,000-token input maximum, and 128,000 output tokens.
  • The unit is the model's own tokens. The same text produces different counts on different tokenizers. Anthropic says the tokenizer introduced with Claude Opus 4.7 produces about 30% more tokens for the same text than earlier Claude models. Count with the model you will call.
ONE CONTEXT WINDOW · GPT-6.2 SOL · 1.05M TOKENS272K · LONG-CONTEXT PRICE922K · MAX INPUTRoom for more inputOUTPUT 128KONE REQUEST · 64K TOKENS · ILLUSTRATIVETools12KSystem3KHistory26KRetrieved docs14KMessage1KOutput reserve8K · OUTPUT
The window of GPT-6.2 Sol drawn to scale, with input capped at 922K so that 128K stays free for output. A typical request is a thin slice of it. The breakdown of that request is illustrative.

What fills the context window in a real request

In a production request the user's new message is usually the smallest component. Five other things fill the window before the model writes a word.

ComponentWhat it containsHow it grows
Tool definitionsNames, descriptions, and JSON schemas for every tool the model can callWith every tool or MCP server you connect
System promptInstructions, policies, examples, output formatWith every rule added after an incident
Conversation historyEarlier user turns, model replies, tool calls, and tool resultsEvery turn, and fastest in agent loops
Retrieved documentsPassages from search, RAG, files, or web fetchesWith top-k and chunk size
Output reserveThe space held for the answer, set by max_tokens or max_output_tokensWith the cap you set, and with reasoning effort

Tool definitions are the component teams underestimate most. Anthropic's tool search docs describe a typical setup of five MCP servers (GitHub, Slack, Sentry, Grafana, and Splunk) that uses about 55,000 tokens in definitions before any work starts. Built-in tools are not free either. On Anthropic's pricing page, declaring the browser use toolset adds about 6,600 input tokens and the computer use toolset about 4,500, and providing any tool adds a tool-use system prompt of 286 tokens on Claude Opus 5.5.

Retrieved content is the next largest. The same page estimates an average 10 kB web page at about 2,500 tokens and a 500 kB research paper PDF at about 125,000. One fetched paper can be larger than everything else in the request combined.

History grows on its own. In an agent loop each tool result becomes part of the input for every later turn, so a 20,000-token file read on turn 3 is still being read, and billed, on turn 40.

Reasoning belongs in the output reserve. Thinking tokens count toward the window and are billed as output, according to Anthropic's docs. On current Claude models the API keeps earlier thinking blocks in the history by default, where they count as input on later turns. OpenAI's Responses API caps reasoning and visible output together under max_output_tokens.

Context engineering covers how to budget each of these and in what order to place them.

Context window sizes for current models

As of November 23, 2026, the current models from Anthropic, OpenAI, and Google all list context windows of about one million tokens. The output limits and how each vendor counts input differ.

ModelContext windowMax output per callNote
Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.21M tokens128K1M is the default, with no beta header
Claude Sonnet 4.5, Haiku 4.5200K tokens64KOlder models still in service
GPT-6.2 Astra, GPT-6.2 Sol, GPT-6 Luna1,050,000 tokens128,000Input capped at 922,000
Gemini 4 Carbon, Neon, Hydrogen, Argon1M tokens (1,048,576)64K synchronousUp to 1M output with long decode

Figures come from Anthropic's models overview, OpenAI's model comparison and GPT-6.2 Sol page, and Google's Gemini models list and Gemini 4 Carbon page, which describes the window as a unified input and output token limit. Vendors change these numbers with each release, so read the model page or query the API before you hard-code one. Anthropic's Models API returns max_input_tokens and max_tokens for every model.

A million tokens is less text than it sounds. Anthropic estimates 1M tokens at about 555,000 English words on its current tokenizer, and code, JSON, and non-English text usually take more tokens per word.

Self-hosted models have a second ceiling. The window a serving engine can offer is bounded by the memory available for the KV cache, and long requests reduce how many requests fit in a batch. The KV cache article works through that memory math.

What happens when a request exceeds the context window

When the input alone exceeds the window, the call fails. Anthropic returns a 400 invalid_request_error ("prompt is too long") on every model, and the failover article lists OpenAI's equivalent, context_length_exceeded. Retrying the same request cannot succeed, so classify this error as permanent and shorten the input.

When input fits but input plus the output cap does not, behavior differs by vendor and model:

  • On Claude 4.5 and newer models, the API accepts the request. If generation reaches the limit, it stops with stop_reason: "model_context_window_exceeded". Older Claude models reject the request with a validation error.
  • On OpenAI, the model pages list a maximum input separate from the window (922,000 tokens on GPT-6.2 models), and the conversation state guide warns that tokens generated past the window may be truncated.

In both cases the answer can end early without an error status. Check the stop reason or response status on every call, and treat a truncated answer the way you would treat an error.

Compaction is the standard fix for long conversations. Anthropic offers server-side compaction in beta for Claude 4.6 and later models, which summarizes earlier parts of the conversation so it can continue past the limit. Context rot covers compaction, tool-result clearing, and sub-agents as ways to keep the window small.

What a long context costs

Every token in the window is billed on every call, and long prompts can cross a price threshold that raises the rate for the whole request.

Start with the flat rate. On Claude Sonnet 5.5 at $2 per million input tokens, a 200,000-token prompt costs $0.40 in input alone. An agent that resends that prompt on 50 turns pays $20 for input before counting output. Anthropic bills the full 1M window at standard rates on Claude 4.6 and later models: a 900K-token request pays the same per-token rate as a 9K-token one.

Two of the three vendors add long-context tiers on some models:

  • OpenAI. On GPT-6.2 Astra, GPT-6.2 Sol, and GPT-6 Luna, a request with more than 272K input tokens pays double the input and cache rates and 1.5 times the output rate, for the full request. On GPT-6.2 Sol a 272,000-token prompt costs $0.544 in input and a 273,000-token prompt costs $1.092, because the higher $4 rate applies to every token once the threshold is crossed.
  • Anthropic. Claude Haiku 5.5 charges $0.10 per million input tokens for prompts up to 100,000 tokens and $0.50 above that, with output rising from $0.50 to $2.50. The prompt length includes cache reads and writes, so a mostly cached 120K-token prompt still pays the higher rate.
  • Google. Gemini 4 Carbon's pricing lists one input rate with no separate long-context tier.

A threshold turns a gradual cost into a step. Keep requests that sit near one measurably below it, or move them to a model whose pricing has none.

Caching changes what you pay for a repeated prefix, not whether it occupies the window. Anthropic's docs state that cached prefixes still count toward the limit. A cache read on Sonnet 5.5 costs $0.10 per million tokens, so the 200,000-token prefix above drops from $0.40 to $0.02 per call after the first write. Prompt caching explains how to keep that prefix stable, and LLM cost optimization ranks trimming context among the other cuts.

What a long context does to latency

A longer input delays the first token, because the model must process every uncached input token before it writes anything. Google's long context guide says every request has some fixed latency, but longer queries generally have a higher time to first token. OpenAI's latency guide says a long prompt can delay the first token, especially when much of the input is new.

Caching is the main lever for latency too. When Anthropic launched prompt caching in 2024, it reported a 100,000-token cached prompt dropping from 11.5 seconds to 2.4 seconds to first token. Output speed does not depend on caching, so a long answer still takes as long to stream.

The output reserve affects latency only through what the model actually generates. A large max_tokens value costs nothing by itself, but higher reasoning effort and long answers do. Time to first token covers how to measure each part of the wait.

Why a bigger context window can make answers worse

Model accuracy declines as input grows, well before the window is full. Anthropic's context window docs name the effect directly: as token count grows, accuracy and recall degrade, which it calls context rot. Google's long context guide notes that its models score highly when retrieving a single fact from a long input, but perform less accurately when a request depends on several facts spread through it.

Three practical rules follow:

  • Treat the advertised window as a ceiling, not a target. The longest input a model handles well for your task is shorter, and only your own evals can measure it.
  • Put the question at the end. Google's guide says performance is usually better when the query comes after all the other context.
  • Remove what the task does not need: unused tools, stale tool output, and passages the reranker scored low.

Context rot covers the research and the benchmarks that separate the advertised window from the effective one, and context engineering covers what to cut and how to order what stays.

How to choose a context window size

Choose a model and window by measuring how large your requests are, then check how the model performs and what it charges at that size.

  1. Measure the real distribution. Log the input tokens on every request, split by component, and look at the 50th, 95th, and 99th percentiles. Anthropic's token counting endpoint is free to call and returns an estimate before you send.
  2. Set the output cap from the task. Reserve what the longest valid answer plus reasoning needs, and alert when responses end on a length or window stop reason.
  3. Check price thresholds. If the 95th percentile sits near 100K on Claude Haiku 5.5 or 272K on GPT-6.2, a small trim avoids a large price step.
  4. Evaluate at your length. Run your eval suite with inputs at your 95th-percentile size, not only short test cases. If scores fall as inputs grow, the fix is a smaller context, not a larger model.
  5. Leave headroom for growth. Agent histories and retrieval results grow over a session. Trigger compaction at a threshold well below the limit, so a long session never hits the hard error.

Frequently asked questions

What is a context window in an LLM?

A context window is the maximum number of tokens a model can process in one request, counting both the input and the output. It includes the system prompt, tool definitions, conversation history, documents, reasoning tokens, and the response. Anything beyond it is rejected or truncated.

Does the output count toward the context window?

Yes. Input and output share one window, so the room you reserve for output is room you cannot use for input. OpenAI's GPT-6.2 Sol, for example, has a 1,050,000-token window and caps input at 922,000 tokens so that 128,000 remain for output.

How big is the context window of current models?

As of November 23, 2026, current Claude models, OpenAI's GPT-6.2 models, and Google's Gemini 4 models all list windows of about one million tokens. Maximum output per synchronous call is 128K on Claude and GPT-6.2, and 64K by default on Gemini 4.

Is a bigger context window always better?

No. Accuracy falls as input grows, often far below the advertised limit, and long inputs cost more and take longer to start answering. A bigger window helps when a task truly needs a lot of material at once. For most requests, a smaller, better-chosen context gives better answers for less money.

What happens when you exceed the context window?

If the input alone is too long, the API returns an error and the request must be shortened. If the input fits but the answer runs out of room, the response stops early, which Claude reports as a model_context_window_exceeded stop reason. Check the stop reason on every call, because a truncated answer can arrive without an error status.

Sources

  1. 01Context windowsClaude API docs
  2. 02Models overviewClaude API docs
  3. 03PricingClaude API docs
  4. 04Tool search toolClaude API docs
  5. 05Token countingClaude API docs
  6. 06Compare modelsOpenAI API docs
  7. 07GPT-6.2 SolOpenAI API docs
  8. 08Conversation stateOpenAI API docs
  9. 09Latency optimizationOpenAI API docs
  10. 10Gemini modelsGoogle AI Studio docs
  11. 11Gemini 4 CarbonGoogle AI Studio docs
  12. 12Long contextGoogle AI Studio docs
  13. 13Prompt caching with ClaudeClaude blog