GLM-5.2 is live — Z.AI's flagship with a 1M-token lossless contextfrom $0.900 per 1M tokens
What Is the Context Window in Claude, and What Counts
2026/07/27

What Is the Context Window in Claude, and What Counts

The context window in Claude is 1M tokens on current models, but tool definitions, retained thinking and cached input all consume it. More is not better.

The context window is everything Claude can reference while generating a response, including the response itself. Anthropic calls it working memory, as distinct from the training corpus[1].

The part worth internalizing is the sentence Anthropic puts right after that definition: more context is not automatically better. As token count grows, accuracy and recall degrade, a phenomenon the documentation names context rot[1]. Curating what goes in matters as much as how much room there is.

TL;DR

  • 1M tokens on current models: Opus 5, Opus 4.8/4.7/4.6, Sonnet 5, Sonnet 4.6, Fable 5, Mythos 5. Others including Sonnet 4.5 are 200k[1].
  • 1M is the default. No beta header, and long-context requests bill at standard pricing[1].
  • Output counts too, including extended thinking, and max_tokens caps 128k on 1M-window models[1].
  • Everything in the request counts: system prompt, every message, tool results, images, documents, and tool definitions[1].
  • Newer models keep previous thinking blocks by default, so they bill as input on later turns[1].
  • Sonnet models get a live token budget injected; Opus and Fable do not[1].

What actually counts

What occupies a Claude context window: system prompt, tool definitions, messages with tool results and images, retained thinking blocks billed as input again, and this turn output capped at 128k

The common mistake is budgeting only for the conversation. The full list[1]:

  • The system prompt
  • Every message in messages, including tool results, images, and documents
  • Your tool definitions
  • The output Claude generates this turn, including its extended thinking

Every response reports what the request consumed in its usage field. With prompt caching the input count splits across input_tokens, cache_read_input_tokens, and cache_creation_input_tokens, and all three count toward the window[1]. Cached does not mean free of the window; it means cheaper per token.

To size a request before sending it, use the token counting API rather than estimating from character count.

Sizes, and what 1M actually costs

ModelsContext window
Opus 5, Opus 4.8, Opus 4.7, Opus 4.61M
Sonnet 5, Sonnet 4.61M
Fable 5, Mythos 51M
Sonnet 4.5 and other earlier models200k

Two details that save money and confusion[1]:

1M is the default on those models. There is no beta header to send, and a 900k-token request bills at the same per-token rate as a 9k one. There is no long-context surcharge.

Max output is 128k on any 1M-window model, regardless of how much input room remains.

A single request can carry up to 600 images or PDF pages (100 on 200k-window models), and large payloads can hit request-size limits before they hit the token limit[1].

Thinking changes the arithmetic

Thinking tokens are a subset of max_tokens, bill as output, and count toward rate limits. With adaptive thinking the allocation varies per request, so the usage is not predictable from prompt length alone[1].

The behavior that surprises people is what happens to previous turns' thinking.

On Opus 4.5 and later, Sonnet 4.6 and later, Fable 5, and Mythos 5, the API keeps previous thinking blocks by default, and they count toward the window like any other input tokens. They were billed once as output when generated, and the kept blocks are then billed as input on every later request that carries them[1].

On earlier Opus and Sonnet models and all Haiku models, the API strips them automatically when you pass them back.

If a long agentic conversation is consuming context faster than the visible transcript explains, retained thinking is usually why. Thinking block clearing overrides the default in either direction.

Context awareness: some models know, some do not

This is the split most people are unaware of[1].

Sonnet 5, Sonnet 4.6, Sonnet 4.5, and Haiku 4.5 track their remaining budget. The API injects the total into the system prompt of every request:

<budget:token_budget>200000</budget:token_budget>

and updates it after each tool call:

<system_warning>Token usage: 35000/200000; 165000 remaining</system_warning>

This is automatic. You never send these tags yourself, and image tokens are included in the counts.

Opus 4.7 and later, Fable 5, and Mythos 5 do not receive these tags. For those, give the model an explicit budget with task budgets, currently in beta.

The practical consequence: a Sonnet model can pace a long task against the space that remains, while an Opus model cannot unless you tell it. That is a real behavioral difference between tiers that has nothing to do with capability scores.

When conversations outgrow the window

Two server-side mechanisms, both worth knowing before you build your own truncation[1].

Compaction automatically summarizes earlier parts of the conversation on the server so it can continue past the limit. Beta, on Claude 4.6 and later.

Context editing offers more targeted strategies, including clearing old tool results in agentic workflows, which is usually where the bulk of a long conversation's tokens actually live.

Reaching for either is better than a homegrown "drop the oldest messages" loop, which tends to discard the system-level context that made the conversation coherent.

Working with it

Curate, do not fill. Context rot is documented behavior, not a rumor. A 900k-token prompt is not automatically better than a well-chosen 90k one.

Count tool definitions. They are in every request, and a large tool schema is a fixed tax on every turn.

Watch retained thinking on newer models during long agentic runs.

Pick the tier with the behavior you need. If a model needs to pace itself across a long task, Sonnet's injected budget does that natively.

from openai import OpenAI

client = OpenAI(api_key="YOUR_REAPI_KEY", base_url="https://api.reapi.ai/v1")

resp = client.chat.completions.create(
    model="claude-opus-5",
    messages=[{"role": "user", "content": "Read this repository and summarize the architecture."}],
    max_tokens=16000,
)
print(resp.usage)   # the number to reconcile against

Rates for the 1M-window models are on reapi.ai/models.

FAQ

What is the context window in Claude?

All the text the model can reference while generating a response, including the response itself. It is working memory, not training data[1].

How big is Claude's context window?

1M tokens on Opus 5, Opus 4.8/4.7/4.6, Sonnet 5, Sonnet 4.6, Fable 5, and Mythos 5. Earlier models including Sonnet 4.5 are 200k[1].

Does using the full 1M window cost extra?

No. On models with a 1M window, 1M is the default and requests bill at standard pricing with no long-context surcharge[1].

What counts toward the context window?

System prompt, all messages including tool results and images and documents, tool definitions, and the output including extended thinking. Cached input counts too[1].

Why is my context filling faster than the conversation suggests?

On newer models the API keeps previous thinking blocks by default, and they count as input on later turns[1].

Is more context always better?

No. Anthropic documents that accuracy and recall degrade as token count grows, a phenomenon called context rot[1].

How many images can one request carry?

Up to 600 images or PDF pages on 1M-window models, 100 on 200k-window models, subject to request size limits[1].

What happens when a conversation exceeds the window?

Use server-side compaction, which summarizes earlier turns so the conversation continues, or context editing to clear old tool results[1].

Budgeting the window instead of filling it

The number everyone quotes about the context window in Claude is 1M, and it is the least interesting fact about it. What decides whether a long-context integration works is the accounting: tool definitions riding along on every turn, retained thinking blocks billing as input, cached tokens still consuming space, and output competing for the same budget.

Anthropic's own framing is the right one to adopt. The window is working memory, more of it is not automatically better, and what you choose to put in it matters more than how much room is left.

References

  1. Anthropic. Context windows — sizes by model, what counts, thinking behavior, context awareness, compaction, and overflow. Retrieved July 2026 from docs.claude.com/en/docs/build-with-claude/context-windows

Further reading