# Context window

> A context window is all the text a model can reference when answering, including its own reply. What counts toward it, Claude

Canonical: https://scaplet.com/glossary/context-window

Glossary Glossary · AI search

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fcontext-window%20(%22Context%20window%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fcontext-window%20(%22Context%20window%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fcontext-window%20(%22Context%20window%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fcontext-window%20(%22Context%20window%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

## 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

_01_At a glance

## What fills the window

Anthropic's docs list what counts: the [system prompt](/glossary/system-prompt), every message including tool results, images and documents, and your tool definitions. The output [Claude](/ai-search/anthropic/ads) generates for the turn counts too, including [extended thinking](/glossary/extended-thinking). In a multi-turn API conversation, previous turns are preserved completely, so each turn's input is the full history plus the new message.

Piece

### System prompt

Counts toward the window?

Yes

Piece

### Earlier user and assistant messages

Counts toward the window?

Yes, preserved in full on the API

Piece

### Tool definitions and tool results

Counts toward the window?

Yes

Piece

### Images and documents

Counts toward the window?

Yes

Piece

### The reply being generated

Counts toward the window?

Yes

Piece

### Cached prompt prefixes

Counts toward the window?

Yes, caching changes billing, not whether [tokens](/glossary/tokenization) count

_02_At 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": [ ... ] }
```

_03_Checklist

## 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.

First_1_
If input alone exceeds the window, the API returns a 400 `invalid_request_error` (prompt is too long).

Next_1_
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.

Then_1_
For long agent runs, Anthropic recommends server-side compaction, which summarizes earlier parts of the conversation. It is in beta.

**More context is not a fix for noisy context**Anthropic says curating what is in context matters as much as how much room exists. Stuffing a long window with loosely relevant text can lower recall rather than raise it.

_04_How it works

## Check it in 2 minutes

See [tokenization](/glossary/tokenization) for how text becomes tokens and [retrieval-augmented generation](/glossary/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.

_01_ Is 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. 01 [Context windows (Claude docs)](https://platform.claude.com/docs/en/build-with-claude/context-windows) platform.claude.com · checked 2026-11-01
2. 02 [Token counting (Claude docs)](https://platform.claude.com/docs/en/build-with-claude/token-counting) platform.claude.com · checked 2026-11-01

## Keep learning

[All glossary](/glossary)

[Learn Model Context Protocol AI search](/glossary/model-context-protocol) [Related Retrieval-Augmented Generation AI search](/glossary/retrieval-augmented-generation) [Read next Tokenization AI search](/glossary/tokenization) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in glossary
[Content strategy](/glossary/content-strategy) [Content syndication](/glossary/content-syndication) [Conversion rate](/glossary/conversion-rate)

More in AI search
[Vector search](/glossary/vector-search) [AI Agents](/glossary/ai-agents) [AI citations](/glossary/ai-citations) [AI detection](/glossary/ai-detection) [AI Hallucination](/glossary/ai-hallucination) [AI Mode](/glossary/ai-mode) [AI Overviews](/glossary/ai-overviews) [AI search](/glossary/ai-search) [AI visibility](/glossary/ai-visibility) [Answer engine optimization](/glossary/answer-engine-optimization) [ChatGPT search](/glossary/chatgpt-search) [Chunking](/glossary/chunking) [Context window](/glossary/context-window) [Conversational AI](/glossary/conversational-ai) [Embeddings](/glossary/embeddings) [Extended thinking](/glossary/extended-thinking) [Fine-tuning](/glossary/fine-tuning) [Generative engine optimization](/glossary/generative-engine-optimization) [Grounding](/glossary/grounding) [Knowledge cutoff](/glossary/knowledge-cutoff) [Large Language Model](/glossary/large-language-model) [Model Context Protocol](/glossary/model-context-protocol) [Multimodal AI](/glossary/multimodal-ai) [Prompt caching](/glossary/prompt-caching)

Terms on this page
[System prompt](/glossary/system-prompt) [Extended thinking](/glossary/extended-thinking) [Tokenization](/glossary/tokenization) [Retrieval-Augmented Generation](/glossary/retrieval-augmented-generation)

Free · 2 minutes

## Know the term. _Now check your site._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **+212%** organic clicks in 90 days Ledgerly
