CyberFreezeDev Loading
  1. Home
  2. AI glossary
  3. Tokens

What are tokens in AI?

Chunks of text a language model reads and writes, which set limits, speed and cost.

3D render of a phone sending chat bubbles into a three lane CRM pipeline board

The plain definition

A token can be a word, part of a word or a symbol, and models split text differently. In English, 100 tokens is about 75 words.

Read more about The plain definition

A token is a unit of text from a model's vocabulary. It can be a whole word ("invoice"), part of a word ("recon" + "ciliation"), a space with a word, a number fragment or a punctuation mark. Each model family has its own tokenizer, so the same sentence can be a different number of tokens on different models.

OpenAI's rule of thumb for English is that one token is about four characters, or about three quarters of a word, so 100 tokens is roughly 75 words (OpenAI help). Treat that as an estimate only.

How tokenization works

  1. 01 Build a vocabulary

    Before training, an algorithm learns the most useful frequent text chunks.

    Read more about Build a vocabulary

    Before training, an algorithm such as byte-pair encoding scans a large text sample and learns the most useful frequent chunks, typically tens of thousands to a few hundred thousand of them.

  2. 02 Split the input

    Your text is broken into the longest matching chunks from that vocabulary.

    Read more about Split the input

    Your text is broken into the longest matching chunks from that vocabulary.

  3. 03 Map to numbers

    Each token becomes a number ID, the only thing the model works with.

    Read more about Map to numbers

    Each token becomes an integer ID. The model only ever works with these IDs.

  4. 04 Generate and decode

    The model outputs token IDs one at a time, which are turned back into text.

    Read more about Generate and decode

    The model outputs token IDs one at a time, and the tokenizer turns them back into text.

Where it matters in business

API bills

Hosted models charge per input and output token, so long prompts at volume add up.

Read more about API bills

Hosted models charge per million input and output tokens, with output usually priced higher. Long prompts on high-volume tasks add up.

Limits

The context window is measured in tokens, not pages or words.

Read more about Limits

The context window is measured in tokens, not pages or words.

Indian languages

Tamil, Hindi and other scripts often use several times more tokens per word.

Read more about Indian languages

Tamil, Hindi and other scripts often take several times more tokens per word than English on many tokenizers, which raises cost and uses up context faster.

A practical example

Most of the cost was a 2,000-word instruction block sent with every WhatsApp enquiry. Trimming it, RAG and prompt caching cut tokens without changing the answers.

Read more about A practical example

A business sends every WhatsApp enquiry to an LLM with a 2,000-word instruction block attached. Most of the cost is that repeated block, not the customer's message. Cutting the instructions to what the task needs, moving reference material into RAG so it is only included when relevant, and using the provider's prompt caching where offered, reduces tokens per message without changing the answers.

Common mistakes

Estimating cost in words

Count with the model's own tokenizer on real inputs, not by words.

Read more about Estimating cost in words

Count with the model's own tokenizer, such as OpenAI's tiktoken, on a sample of real inputs.

Forgetting output tokens

Verbose answers cost more and take longer. Ask for the length you need.

Read more about Forgetting output tokens

Verbose answers cost more and take longer. Ask for the format and length you need.

Expecting exact character work

Counting characters or reversing strings is a weak spot. Do those in code.

Read more about Expecting exact character work

Because models see tokens, not letters, tasks like counting characters or reversing strings are weak spots. Do them in code.

Questions

Do images and audio use tokens too?

Yes. Multimodal models convert images and audio into tokens as well, and providers publish how they count them. A single image can cost hundreds or thousands of tokens depending on size.

Do we pay for tokens on a self-hosted model?

Not per token. You pay for the hardware and power, so tokens matter for speed and for how many requests one GPU can serve rather than for a bill.

Last updated