Tokens and context windows
EasyTokensContext window
What are tokens, and what is a context window? Why do they matter in practice?
TL;DR
Tokens are the units an LLM reads and writes: usually sub-word pieces produced by an algorithm like BPE. In English, one token is about ¾ of a word (roughly 4 characters). The context window is the maximum number of tokens the model can handle in one request: system prompt, conversation history, retrieved documents, tool definitions and the generated output together. Tokens matter because they determine cost (you pay per input and output token), latency (output tokens are generated one at a time), and what fits in a request.
Key points
- Hebrew, Arabic, code and many non-English languages often use more tokens per word, so the same content costs more and fills the context faster.
- Output tokens usually cost several times more than input tokens.
- When history grows past the window, you must truncate, summarize or retrieve; the API won't do it for you.
- "Lost in the middle": models use information at the start and end of a long context more reliably than the middle. A bigger window doesn't mean perfect recall.
- Long contexts cost more and slow down the first token. RAG or summarization is often cheaper than stuffing everything in.
- Count tokens with the provider's tokenizer or token-counting API before sending, especially for large inputs.
Example
text
"unbelievable" → ["un", "believ", "able"] 3 tokens
"שלום עולם" → often 4–6 tokens, more than the English "hello world" (2)Common follow-ups
- Why not just use the biggest context window for everything? Cost, latency and weaker recall in the middle. Retrieval keeps prompts focused.
- What's prompt caching? Providers can cache a long, repeated prefix (system prompt, documents), so later requests that share it are cheaper and faster.
What interviewers look for
Tip
Tokens as sub-words, the window covering input plus output, and the practical impact on cost, latency and design.
- Red flag: treating tokens as words, or forgetting output tokens count toward the window.