Free auditStart free
GlossaryGlossary · AI search

Context window

A context window is all the text a model can reference when answering, including its own reply. What counts toward it, Claude's sizes, and how to check usage.

2 min
read
2
sources
Oct 30, 2026
updated
Scaplet Editorial Team
author
In one line

A context window is all the text a language model can reference when generating a response, including the response itself. Anthropic describes it as working memory, separate from the data the model was trained on. Bigger is not automatically better: Anthropic says accuracy and recall degrade as token count grows, which it calls context rot.

30-second check

Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode

At a glance

4 facts from the sources below
System prompt, messages, tool results, tool definitions, output
Counts toward it
1M tokens on current models, 200k on others
Claude sizes
400 error if input alone exceeds the window
Overflow
max_tokens caps one reply
Related limit
02At a glance

Anatomy of a request and its usage

Field

system

Role in the window
Input tokens, every request
Field

messages

Role in the window
Input tokens: full history plus the new turn
Field

tools

Role in the window
Input tokens for the definitions, plus any tool results later
Field

max_tokens

Role in the window
Upper bound on output, which also counts toward the window
Field

usage in the response

Role in the window
Reports what the request consumed
A request body, and where the tokens go
{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "system": "You are a support agent.",
  "messages": [
    {"role": "user", "content": "Summarize this ticket thread..."}
  ],
  "tools": [ ... ]
}
03Checklist

Sizes and overflow

Anthropic's docs say current models such as Claude Sonnet 5.5, Opus 5.5 and Haiku 5.5 have a 1M-token context window, while other Claude models, including the deprecated Claude Sonnet 4.5, have 200k. A single request can generate up to 128k output tokens on the 1M models. Model lists change, so confirm against the model comparison table.
First1
If input alone exceeds the window, the API returns a 400 invalid_request_error (prompt is too long).
Next1
On Claude 4.5 models and newer, if input plus max_tokens exceeds the window, the request is accepted and generation stops with stop_reason: "model_context_window_exceeded" if it hits the limit.
Then1
For long agent runs, Anthropic recommends server-side compaction, which summarizes earlier parts of the conversation. It is in beta.
04How it works

Check it in 2 minutes

See tokenization for how text becomes tokens and retrieval-augmented generation for fetching only the passages a request needs.

  1. 01

    Read the usage field

    Every response reports consumed tokens in its usage field. With prompt caching the input count is split across input_tokens, cache_read_input_tokens and cache_creation_input_tokens, and all three count.

  2. 02

    Estimate before sending

    Use the token counting API on a draft request. Anthropic calls the result an estimate that may differ by a small amount.

  3. 03

    Recount per model

    Anthropic says Claude 4.7 and later models use a newer tokenizer that produces approximately 30 percent more tokens for the same text, so recount against the model you plan to use.

Questions

Asked a lot.

1 questions people ask next, answered from the sources on this page.

01Is the context window the same as the training data?

No. Anthropic distinguishes the two: the context window is the working memory for one request, while training data is the large corpus the model learned from earlier.

Sources · 2

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • claude.com
  1. 01Context windows (Claude docs)platform.claude.com · checked 2026-11-01
  2. 02Token counting (Claude docs)platform.claude.com · checked 2026-11-01
Free · 2 minutes

Know the term. Now check your site.

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly