Skip to the page

LLM basics for builders · core

Tokens and the context window

A token is a piece of text from the model's tokenizer, often part of a word. Cost, rate limits and the context window are all counted in tokens, and the window holds everything: instructions, tools, history, retrieved text and the reply.

The notes

What you must know

  • A token is a piece of text made by the tokenizer (byte-pair encoding or similar). It is often part of a word, so a token is not a word.
  • In English a token is about three quarters of a word on average, so 1,000 words is roughly 1,300 to 1,500 tokens. Numbers, code and rare words break into more pieces.
  • Prices, rate limits (tokens per minute) and the context window are all counted in tokens.
  • Output tokens usually cost several times more than input tokens. They are made one at a time, so they also drive latency.
  • The context window holds the system prompt, tool definitions, chat history, retrieved chunks, the user message and the reply. Long chats and big tool lists use it up quietly.
  • Many tokenizers were trained mostly on English. Hindi and other Indian languages usually need more tokens for the same meaning, so the same answer costs more, takes longer and fewer chunks fit.
  • Count with the model's own tokenizer or the provider's token-counting feature, not with characters divided by four, when the number matters. Different model families tokenize differently, so a model switch changes costs.

The red pen

Common traps: mistake → fix

  • Mistake: A token is a word

    Fix: a token is a piece of text, often smaller than a word.

  • Mistake: The context window is only for the user's message

    Fix: it also holds system prompt, tools, history, retrieved text and the reply.

  • Mistake: Hindi costs the same as English

    Fix: it usually needs more tokens, so it costs more and uses more of the window.

Easy to hard

Questions interviewers ask, easy to hard

  1. What is a token? Why does a developer care?
  2. Roughly how many tokens is a 1,000-word English email?
  3. What fills the context window besides the user's message?
  4. Why does the same sentence in Hindi usually cost more than in English?
  5. How do you count tokens before you send a request?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview