What are tokens and the context window?
AI models do not read words, they read tokens, and they can only hold so many at once. Knowing both explains AI bills, forgotten instructions and why shorter prompts often work better.

Key takeaways
- A token is a chunk of text, often part of a word; in English a rough rule is about four characters per token.
- The context window is the maximum number of tokens a model can take in, prompt and reply together, in one request.
- AI usage is metered in tokens in and tokens out, so long histories and pasted documents cost more on every call.
Tokens are the small chunks of text, often whole short words or pieces of longer ones, that a language model actually reads and writes, and the context window is the maximum number of tokens the model can work with in a single request, counting your instructions, any documents or chat history you include, and its own reply.
An everyday comparison: a desk. Tokens are the sheets of paper; the context window is the size of the desk. Everything the model should consider has to fit on the desk at the same time. Anything that does not fit is, for that request, as if it did not exist.
What a token is
Models split text with a tokenizer that learned common chunks. "Book" is likely one token; "unbookable" might be three ("un", "book", "able"). Spaces and punctuation are part of tokens too. Rough rules for English, useful for estimates only: about four characters or three-quarters of a word per token, so 1,000 words is in the region of 1,300 tokens. Code, numbers and many non-English languages use more tokens per word, so the same message can cost noticeably more in another language.
The context window
Each model has a fixed limit. Current models range from tens of thousands of tokens to over a million. Three things share that space in every request:
- 01Instructions: the system prompt that sets the role and rules.
- 02Context: chat history, retrieved documents, file contents, tool results.
- 03The reply: output tokens count against the window too, and models also have a separate cap on how long one reply can be.
A bigger window does not mean perfect attention. Models can miss details buried in the middle of very long inputs, so including only what is relevant often gives better answers than including everything. That is the idea behind RAG: fetch the few passages that matter instead of pasting the whole manual.
Why it matters when you build with Startbase
On the building side, context is why focused requests work. Startbase credits track the work the agent does and vary with context and work performed, and the docs advise sending only the context and attachments a task needs. Project Knowledge (up to 8,000 characters) is added to every turn, so keep it to the rules that really apply everywhere (custom knowledge docs). When a long thread drifts, planning before you build and small steps beat one giant prompt.
On the app side, if your app calls AI through the Startbase Cloud gateway, the Backend tab shows calls, tokens in and out, and cost, and you can cap runtime spend per app (AI features docs). Design with tokens in mind:
- For chat features, send the last 10 to 20 messages plus a short running summary, not the entire history, as a starting point to tune.
- Trim documents to the relevant sections before sending them.
- Ask for concise, structured replies when you only need a few fields; output tokens usually cost more than input tokens.
The cost of building an AI app puts these per-call costs into a monthly budget.
Common confusions
- Tokens vs words vs characters. Limits and prices are in tokens. Word counts are only an approximation.
- "The model forgot." In a long chat, early messages may have been dropped or summarized to fit the window. Restate key constraints when it matters.
- Context window vs training data. The window is short-term working space for one request. The model's general knowledge comes from training and does not grow with what you paste in.
Frequently asked questions
How can I count the tokens in my text?
Many model providers publish free tokenizer tools that show exactly how text is split. For quick planning, divide the character count by four for English.
What happens if my request exceeds the context window?
The request fails or the app has to cut something, usually the oldest messages. Well-built apps summarize or retrieve only relevant parts before that happens.

