Token
A chunk of text, about 4 characters or three quarters of an English word. Models read and write tokens, not letters.
Last updated
Analogy
Bytes in a request. You pay per token, and every limit is measured in tokens, like a hosting plan that bills by bandwidth.
Code example
const res = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: "Hi!" }],}); console.log(res.usage);// { prompt_tokens: 9, completion_tokens: 10, total_tokens: 19 }In an agent
Long chats and big tool results eat your token budget. Every loop of an agent costs tokens.
Practice
Flashcards
- What is a token?About 4 characters of text; the unit of cost and limits.
Questions people ask
How many tokens is a word?
In English, one token is about four characters, or roughly three quarters of a word. So 100 words is around 130 tokens. Code, numbers and other languages often use more tokens per word. The exact count comes back in the usage field of every API response, so you never have to guess.
Why do tokens matter for cost?
Providers bill per token, for both the text you send and the text the model writes. Agents resend the whole conversation on every loop step, so long histories and big tool results get paid for again and again. Keeping prompts and tool outputs short is one of the easiest ways to cut an agent's bill.