Early-bird price on the GenAI & Agentic AI Engineer Bootcamp batch. Grab a seat →

A token is the small unit of text that an AI model reads and writes: a word, part of a word or a punctuation mark. The context window is the maximum number of tokens a model can work with at one time, counting your instructions, your documents, the conversation so far and the reply. Together they decide how much a model can take in, how much a request costs and why a long chat can start to lose the thread.

Key takeaways

  • For English, a common rule of thumb is that one token is about four characters, and 100 tokens are about 75 words. The real number depends on the model and the language.
  • Everything counts toward the context window: system instructions, attached files, earlier messages and the model's own answer.
  • A model cannot use anything that is outside its context window. It does not remember earlier chats on its own.
  • Usage-based pricing is charged per token, and output tokens usually cost several times more than input tokens.
  • A larger window is not automatically better. Vendors document that accuracy falls as the context fills up.

If you are new to how language models work, start with generative AI explained, then come back here.

What exactly is a token?

Models do not process text letter by letter or sentence by sentence. A piece of software called a tokeniser first splits the text into tokens, and the model works on those.

Common short words are often a single token. Longer or rarer words are split into pieces, so a long word such as "unbelievable" may become several tokens. Punctuation and spaces matter too. OpenAI's help centre points out that "red", "Red" and " red" with a leading space are not the same text to a tokeniser.

Two useful rules of thumb for English, both from vendor documentation:

  • OpenAI: one token is approximately four characters, or about three-quarters of a word. 100 tokens are approximately 75 words.
  • Google, for Gemini models: a token is about four characters, and 100 tokens are about 60 to 80 English words.

These are estimates, and they shift in two ways:

  • By model. Each model family has its own tokeniser. Anthropic's documentation notes that its newer Claude models use a tokeniser that produces approximately 30 per cent more tokens for the same text than its earlier models did.
  • By language. OpenAI notes that other languages can have a different relationship between characters, words and tokens, so the English ratios may not carry over.

How do I count tokens for my own text?

You have three options, from quickest to most exact.

Estimate from the word count. Divide the number of words by 0.75. This is good enough for planning.

Paste the text into a tokeniser tool. OpenAI provides a web-based tokeniser that shows how text is split for its models.

Ask the API. The main providers offer a counting call. Anthropic's token counting endpoint is free to use and returns the number of input tokens before you send the real request. The documentation's own example, in Python:

import anthropic

client = anthropic.Anthropic()

response = client.messages.count_tokens(
    model="claude-opus-5-5",
    system="You are a scientist",
    messages=[{"role": "user", "content": "Hello, Claude"}],
)

print(response.json())

Anthropic's documentation shows the result as { "input_tokens": 14 }. Notice what that tells you: a six-word request costs 14 tokens, because the count includes structure the API adds around your words, not only the words themselves. Anthropic describes the count as an estimate that can differ slightly from the final figure.

Always count with the model you plan to use. A count taken with one model's tokeniser is not valid for another.

A worked example: one handbook, twenty questions

Suppose an HR team wants to ask questions about a 30,000-word employee handbook. The numbers below are estimates built from the rules of thumb above, not measurements.

Step 1: estimate the input. 30,000 words divided by 0.75 is about 40,000 tokens. On a tokeniser that produces 30 per cent more tokens, the same handbook is about 52,000 tokens. We will use 40,000 to keep the arithmetic simple.

Step 2: estimate the output. A 300-word answer is about 400 tokens.

Step 3: check the fit. 40,400 tokens is far inside a window of 200,000 or one million tokens, so the whole handbook fits in a single request.

Step 4: estimate the cost. As of November 2026, Anthropic's pricing page lists Claude Sonnet 5.5 at $2 per million input tokens and $10 per million output tokens. Prices change, so check the page before you budget.

ItemTokensRate per million tokensCost
Handbook and question (input)40,000$2$0.08
Answer (output)400$10$0.004
One question, total40,400about $0.084

Step 5: multiply by real usage. A model has no memory between requests. Each new question sends the whole handbook again, along with the earlier questions and answers. Twenty questions therefore cost at least 20 times $0.084, about $1.68, and a little more as the history grows.

That is why providers offer prompt caching, which stores the unchanged start of a prompt so it is not charged at full price each time. On the same pricing page, a cached read for Claude Sonnet 5.5 is listed at $0.10 per million tokens, which would bring the 40,000-token handbook down from $0.08 to $0.004 per question after the first one. Caching has its own rules and write costs, so read the provider's documentation before relying on it.

A bar chart compares the listed prices per million tokens for Claude Sonnet 5.5: cached input read at 0.10 dollars, input at 2 dollars and output at 10 dollars.

What is a context window?

The context window is the model's working memory for one request. Anthropic's documentation defines it as "all the text a language model can reference when generating a response, including the response itself", and distinguishes it from the large body of data the model was trained on.

A stack shows what fills a context window from top to bottom: system instructions, attached documents and tool results, the conversation history, your latest message and the reply being written.

What counts toward it:

  • System instructions: the hidden set-up text that tells an assistant how to behave.
  • Documents and tool results: files you attach, web pages a search tool returns, and the definitions of any tools.
  • Conversation history: every earlier message, yours and the model's.
  • Your latest message.
  • The reply: including any private reasoning the model does before answering, on models that have a thinking mode.

Sizes vary by model and change often. As of November 2026, Anthropic's documentation lists a one-million-token context window for many current Claude models and 200,000 tokens for the others. Google's documentation lists a window of 1,048,576 tokens for current Gemini models. Check the vendor's model page for the one you use.

What happens when the window fills up?

It depends on the product:

  • An API returns an error if the input alone is larger than the window. Anthropic's API, for example, rejects the request with a "prompt is too long" message.
  • A chat app may quietly drop the oldest messages. Anthropic notes that chat interfaces can manage the window on a rolling "first in, first out" basis. This is why an assistant sometimes forgets an instruction you gave an hour ago.
  • Some systems summarise older turns to free space, which keeps the gist but loses detail.

The model gives no warning when early material has been dropped. If a long chat starts ignoring your earlier rules, this is the most likely reason.

Why is a bigger context window not always better?

Two trade-offs apply.

Accuracy. Anthropic's documentation states that "as token count grows, accuracy and recall degrade", and calls the effect context rot. A model given 300 pages when four are relevant has more chances to pick the wrong passage.

Cost. You pay for every input token on every request. Sending a whole document library with each question is the expensive way to work.

The practical alternative is to send only the relevant passages. That is the idea behind retrieval, which is also the main defence against made-up answers; see why AI models hallucinate and how grounding reduces it. For developers, the article on how to reduce LLM costs covers caching, batching and shorter context in detail.

How do I work within the limits?

  • Start a new chat for a new task. Old, unrelated history costs tokens and can distract the model.
  • Attach the relevant section, not the whole file, when you know where the answer is.
  • Restate key rules in a long conversation, or put them in the product's custom instructions so they are always present.
  • Ask for a summary before you switch chats, and paste it into the new one. You carry the important points forward at a fraction of the size.
  • Say how long the answer should be. Output tokens cost the most, and a word limit is the simplest control. The article on how to write a prompt that works shows how to set format and length clearly.

Common questions

Is a token the same as a word?

No. Short common words are often one token, but longer words are split into several, and punctuation counts too. For English, 100 tokens is roughly 75 words.

Do images and PDFs use tokens?

Yes. Files are converted into tokens before the model reads them, and they count toward the context window in the same way as text.

Does the model remember my earlier chats?

Not by itself. Each request only contains what is in its context window. Products with a memory feature save notes and add them back into later prompts as ordinary text.

Free download: The AI fundamentals field guide

How large language models work, why they get things wrong, how to write a prompt that works and how to judge a tool before your team adopts it. Plain English, no coding. See what’s inside.