DevPrep

All topics › AI fundamentals for developers

Tokens and the context window: how they're counted and what happens on overflow

Junior PRO

Essence

A token is the unit in which a model reads and writes text, and in which the provider counts money and limits. The context window is the maximum number of tokens the model takes into account in a single request. It includes everything: the system prompt, the entire conversation history, attached files and images, tool descriptions and the model's own answer.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store