AI Context Windows Tutorial: How Much Fits at Once

TL;DRThe context window is how many tokens a model can consider at once — its working memory.

A model can only attend to a fixed number of tokens — its context window (from a few thousand to millions in modern models). Everything the model "knows" in a conversation must fit: system prompt, history, documents, and the reply. Exceed it and earlier content is truncated or must be summarized. Bigger windows cost more compute (attention scales with length), so there's a price for using them.

Key points

Common mistakes

Try it: List what must collectively fit inside the context window.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>context window = system + history + docs + answer
exceed it → oldest content drops
bigger window → more compute/cost</pre></body></html>
Open the interactive lesson →
Tokenization · Bpe · Wordpiece · Unigram Scaling Laws · Params · Data · Compute