DefinitionTokens are small pieces of text, such as whole words, parts of words or punctuation marks, that a language model splits everything it reads and writes into. Tokens measure the length of a prompt and an answer, the limit of text a model can take in at once (its context window) and the charges for using models through an API.
What is a token?
A token is a piece of text a language model works with: sometimes a whole short word, sometimes part of a word, sometimes just a comma. Long or rare words are split into several tokens. The same text can come to a different number of tokens depending on the language and the model, because each provider splits text its own way.
Images and PDFs are also converted into tokens before they reach the model. For you, one thing matters: the more text you send to the model and get back, the more tokens are used.
Why do tokens affect cost?
When a business uses a model through an API, that is from its own software, the provider charges per token: separately for what the model receives (the instruction, documents, conversation history) and for what it writes. Longer instructions and answers mean a bigger bill.
Example: a shop’s website chatbot receives the returns policy, the price list and the whole conversation so far with every question. If the full policy is attached to every question, you pay for it every time. When the model only gets the relevant passages, the number of tokens and the cost go down.
What to look at when planning AI in a business
- Cost estimate. Ask for a calculation of how many tokens a typical case uses and how many cases there are a month. Check per-token prices on the model provider’s own pricing page.
- Length limit. A model can take in only a limited number of tokens at once. Very long documents have to be split, or only the relevant parts passed in.
- Choice of model. For simple tasks, such as sorting emails, a smaller, cheaper model is often enough.
- Monitoring. Agree who sees usage and where, so a fault in an automation cannot run up costs for a week.
How the running costs of a website chatbot add up is covered in the article on an open-source chat widget versus a chatbot subscription.
Frequently asked questions
Is a token the same as a word?
No. Short, common words are often a single token, but longer and rarer ones are split into several. Providers offer tools that show the exact token count for a piece of text.
Do AI tokens have anything to do with crypto or logins?
No. The word “token” has several meanings in computing. Here it means only the pieces of text that a language model reads and writes.
See also
Sources