Token
Also called AI token or tokenization
A small chunk of text, often a word or part of a word, that AI models read and write. Limits, usage, and pricing are counted in tokens.
Add a live token estimate under the message box that updates as the user types, using about 4 characters per token for English. Turn the count amber above 3,000 tokens and red above 4,000, and above 4,000 disable Send with a short explanation.
Paste into Layerwise or any AI coding tool.
What is Token?
Models read text as tokens. Common words are often a single token, while rare words, names, and code get split into several pieces, and spaces and punctuation count too. The splits in the demo are illustrative: every model family uses its own tokenizer, so the same sentence can produce different counts.
Almost everything about using a model is measured in tokens: how much fits in the context window, how long a reply can be, and what a request costs. For English, a rough rule of thumb is about four characters, or three quarters of a word, per token.
Code, languages other than English, and long runs of numbers usually take more tokens than plain English prose. Large files, logs, and screenshots use tokens too, so pointing the AI at only the files it needs keeps a conversation cheaper and more focused.
Common errors
- Context length exceeded
- The text sent to the model, including chat history, documents, and tool results, is more than the model can read in one request.
- You exceeded your current quota
- OpenAI refused the request because the account or project behind the API key is out of credit or has reached a spending limit.
- 429 Too Many Requests
- The service is rate limiting you: too many requests arrived in a short time, so it refuses more until the limit resets.
Related terms
All termsContext window
The amount of text an AI model can consider at once, including your messages, its replies, and the files it reads, measured in tokens.
Prompt
The instruction you give an AI model. In AI coding tools, the prompt describes what to build or change, and its detail shapes the result.
API
A set of rules that lets one program ask another for data or actions, usually by sending a request to a URL and getting JSON back.
Vibe coding
A way of building software by describing what you want to an AI model and steering the result in conversation, without writing the code yourself.