What is a context window?
A definition page for the context window as Anthropic describes it in its Claude documentation. Other labs use the same phrase with their own limits; this page stays with that documentation.
A context window is a limit on what a language model can see in one request, not a measure of what the model was trained on. This page follows Anthropic’s documentation on context windows. The figures and product names below are the ones on that page as it stood when this explainer was written. Other providers publish their own window sizes, and those sizes change.

Working memory, not the training corpus
Anthropic’s documentation says the context window “refers to all the text a language model can reference when generating a response, including the response itself.” It draws a direct contrast with the large corpus the model was trained on. The window, in this wording, is “working memory” for the model. A larger window lets the model handle longer and more complex prompts, but the same page says more context is not automatically better.
As the token count grows, the documentation says, accuracy and recall degrade, a phenomenon it calls context rot. Curating what is in context, it argues, is as important as how much space is available. That is Anthropic’s account of a practical limit, not a claim about a particular benchmark on this page.
What counts against the window
Everything in the request counts, according to the same documentation. That includes the system prompt, every message in the messages list (including tool results, images, and documents), and the tool definitions. The output the model generates for the turn, including its extended thinking, counts too. Each response reports what the request consumed in a usage field.
If a developer uses prompt caching, the input count is split across input_tokens, cache_read_input_tokens, and cache_creation_input_tokens. The documentation is explicit that all three still count toward the window. Caching changes what is paid for those tokens, not whether they occupy space. To estimate a request before sending it, the page points to Anthropic’s token counting API.
The documentation also describes how the window fills across a conversation. As the conversation advances, each user message and assistant response accumulates, and previous turns are preserved completely. Each turn has an input phase, which contains the conversation so far plus the current user message, and an output phase, which generates a response that becomes part of the input for the next turn. A footnote says chat interfaces such as claude.ai can also manage the window on a rolling “first in, first out” basis. That is a product behavior the documentation flags, not a change to the definition of the window itself.
Window sizes in the documentation
The page groups Claude models into two window sizes. It lists a set of models with a 1 million token context window, including named Fable, Mythos, Opus, Sonnet, and Haiku releases, and it says other Claude models have a 200,000 token context window. A single Messages API request to a model with a 1 million token window, it says, can generate up to 128,000 output tokens (max_tokens).
For every model with a 1 million token window, the documentation says 1 million is the default: a beta header is not required, and long-context requests are billed at standard pricing, except on Claude Haiku 5.5, where prompts over 100,000 tokens cost more. A single request can include up to 600 images or PDF pages, or 100 for models with a 200,000 token window. The page notes that many images or large documents can hit request size limits before the token limit.
Those sizes and exceptions are Anthropic’s published figures for its own API. They are not a comparison table for other labs, and they can change when the documentation changes.
Thinking, tools, and earlier turns
When thinking is enabled, the documentation says all input and output tokens, including thinking tokens, count toward the context window limit, with nuances in multi-turn situations. Thinking tokens are a subset of the max_tokens parameter, are billed as output tokens, and count toward rate limits. With adaptive thinking, Claude determines its thinking allocation dynamically, so usage varies from request to request.
Whether thinking blocks from previous assistant turns stay in the window depends on the model. The API, the page says, keeps previous thinking blocks by default on a listed set of later Opus, Sonnet, Haiku, Fable, and Mythos models, and those blocks then count toward the window like other input tokens. On earlier Opus and Sonnet models, and on Haiku models through Claude Haiku 4.5, the API automatically strips previous thinking blocks from the conversation history when they are passed back, which the documentation says preserves token capacity for conversation content. Defaults can be overridden with thinking block clearing.
The same page walks through a tool-use cycle. On the first turn, the tools configuration and the user message are input; thinking, a text response, and a tool-use request can appear in the output; all of those components count toward the window. When tool results are posted back, the documentation says to include the entire unmodified thinking block that accompanied the tool request, including its signature, because the API uses cryptographic signatures to verify authenticity. On models that strip previous thinking blocks, a later user turn no longer has to carry the completed tool-use thinking block as input. Interleaved thinking, the page says, lets the model think between tool calls, including after it receives tool results.
The practical point for this page is not the product detail of every flag. It is that “the context window” includes hidden or auxiliary tokens a reader might not think of as part of the prompt: tool definitions, tool results, images, and, on some models, earlier thinking blocks.
When the window is exceeded
If the input alone already exceeds the model’s context window, the documentation says the API returns a 400 invalid_request_error with the message “prompt is too long,” on every model.
On Claude 4.5 models and newer, if input tokens plus max_tokens exceeds the window size, the API accepts the request. If generation then reaches the window limit, it stops with stop_reason: "model_context_window_exceeded". On earlier models, the API returns a validation error instead, unless a named beta header is used to opt in to the newer stop reason. The page points to Anthropic’s stop-reason documentation for details, and again to the token counting API as a way to stay within limits.
For conversations that regularly approach the limit, the documentation describes server-side compaction, which summarizes earlier parts of the conversation on the server so the conversation can continue past the window limit. It also describes context editing strategies such as clearing old tool results and clearing thinking blocks. Compaction and editing are management tools. They do not change the definition of the window; they change what is still sitting in it.
Context awareness on two models
The page says only Claude Sonnet 4.5 and Claude Haiku 4.5 have context awareness: those models track their remaining context window throughout a conversation. The API injects a token budget in the system prompt and, after each tool call, a warning that reports used and remaining tokens, including image tokens. The documentation says no other model receives those tags, and that Claude Sonnet 4.5 is deprecated on Anthropic-operated platforms, with a pointer to Anthropic’s model deprecations page. That last point is a product status note, not part of the definition of a context window.
How to read this page
A context window, in this documentation, is the working memory of one request and of the conversation history that request carries, including the model’s own output. It is not the training set, and filling it is not the same as making the model more accurate. Anthropic’s page is also explicit that some tokens a developer might treat as “free” — cached prefixes, thinking blocks, tool definitions — still occupy the window.
This page does not list every model from every lab, and it does not say which window size a reader should use. The source for the definition and for the figures above is Anthropic’s context windows documentation. For the architecture many of these models still descend from, see How transformer attention works. For a terminology entry on large language models, see What is a large language model?.