Search⌘ K
AI Features

Understanding Context Windows and Token Limits

Explore how tokens and context windows define the input and output limits for large language models. Understand tokenization methods, token budgeting, and the impact of token constraints on application design. Learn to manage token limits effectively for prompt engineering and retrieval-augmented generation strategies.

A developer building a contract-analysis application pastes a 50-page legal document into the GPT-4 API and hits a wall. The API returns a maximum context length exceeded error, and the entire call fails. No partial summary, no best-effort attempt, just an error. This happens because LLMs do not read raw text the way humans do. Before a model processes a single word, the text is broken into smaller units called tokens, and every model enforces a hard ceiling on how many tokens it can handle in one call.

This lesson answers three questions that sit at the foundation of every LLM application you will ever build. What exactly is a token? How does the tokenization process work? And what is a context window, and why does its size shape every architectural decision you make? Whether you are designing prompts, building retrieval pipelines, or preparing data for fine-tuning, every choice you make is ultimately constrained by token economics. Understanding these mechanics is not optional. It is a prerequisite knowledge for the rest of this course.

What tokens are and how they work

A token is the atomic unit that an LLM’s vocabulary maps text into before any processing begins. Tokens are not always full words. A single token can be a complete word, such as ...