Home › Blog

What is a token in AI: the math behind how much you pay, how much it remembers, and how quickly it responds

By Jesús M. Vázquez-Nicolás, Co-founder (LinkedIn) ·

Automatically translated from Spanish. Read the original in Spanish

What is a token in AI: the math behind how much you pay, how much it remembers, and how quickly it responds

Every time you write to an AI, your message is converted into tokens before the model reads it. With a monthly subscription, you don't see this on your bill, but in the API—which is how companies integrate AI into their systems—each token has a price: you're charged for what the model reads and writes.

In this guide, we explain what a token is, why Spanish is more prevalent than English, and the three simple calculations that determine how much you pay, how well the model remembers you, and how quickly it responds. We use our own measurements and published prices so you can replicate the calculations for your own situation.

What is a token (and what it is not)

A language model doesn't read letters or words: it reads a list of numbers. Before entering the model, the text passes through a tokenizer , which breaks it down into pieces of a fixed vocabulary—on the order of one hundred thousand to two hundred thousand pieces—and changes each piece to its identification number.

To put it in simpler terms: a tokenizer is a function that converts a text into a sequence of integers, text → (t₁, t₂, …, tₙ) . Each tᵢ is a number between 0 and |V| − 1, where |V| is the size of the vocabulary. That n , the length of the sequence, is the number that matters for everything else in this article.

Most vocabularies are built using an algorithm called Byte Pair Encoding (BPE) : it starts with individual characters, searches for the pair of pieces that appears together most frequently in a large corpus, merges them into a new piece, and repeats this process until the vocabulary is complete. This is why frequent words—common words, endings like “-ization”—end up being a single piece, while rare words are made up of several.

Zirve measurement using the OpenAI public tokenizer, encoded for GPT-5.x (October 2026). Each vendor uses its own tokenizer, so the exact cuts vary from model to model.
Word (within a sentence)PartsTokensIn EnglishTokens
intelligenceintelligence1intelligence1
priceprice2quote1
billingfact · uration2billing1
automationautomation2automation1
maturityexpiration2expiration1
tokenizationtoken · ization2tokenization2

A curious fact that shows that the tokenizer does not see words but sequences of characters: “intelligence” in the middle of a sentence, with its space before it, is a single piece; at the beginning of a text, without a space, it is split into three (int · elig · ence).

Why do Spaniards spend more tokens?

Vocabularies are learned from corpora where English dominates, so English words are more likely to be retained as a single unit. Furthermore, Spanish has more forms per word—conjugations, gender, number—and each form competes for a place in the vocabulary. This phenomenon is documented: the study "Language Model Tokenizers Introduce Unfairness Between Languages" (Petrov et al., NeurIPS 2023) found that the same translated text can occupy up to 15 times more tokens depending on the language.

To avoid simply repeating hearsay, we measured it. We took three texts with their English equivalents—a typical email requesting a quote, Article 1 of the Universal Declaration of Human Rights, and the script for our publication on tokens—and ran them through two encodings of OpenAI's public tokenizer : the current one (GPT-5.x) and the previous one (GPT-4).

Own measurement, October 2026. It is a small sample (about 150 words per language): it serves to give an order of magnitude, not as a definitive statistic.
MetricsSpanishEnglish
Words148158
Tokens, GPT-5.x encoding195182
Tokens per word, GPT-5.x1.321.15
Tokens, GPT-4 encoding232183
Tokens per word, GPT-41.571.16

The same content in Spanish used 27% more tokens with the previous encoding and 7% more with the current one. Two lessons: the "Spanish tax" exists, and it depends on the tokenizer; recent vocabularies have greatly reduced it. As a rule of thumb, in Spanish it counts around 1.3 tokens per word : 1,000 words equals about 1,300 tokens.

Be careful when comparing models based solely on their price per token. Since each provider has its own tokenizer, the same text won't occupy the same amount of space across all of them. Anthropic, for example, states in its price list that its models, starting with Claude 4.7, use a tokenizer that produces approximately 30% more tokens for the same text than previous versions. What you should compare is the cost per task, not the price per token.

The three things that tokens decide

1. How much you pay: a linear account… that becomes quadratic

The cost of each call to a model is a simple sum. Prices are published per million tokens:

Cost = (input tokens × entry price + exit tokens × exit price) ÷ 1,000,000

Output tokens—what the model writes—cost more than input tokens. In Anthropic's October 2026 price list, Claude Sonnet 5.5 charges $2 per million input tokens and $10 per million output tokens: five times more for writing than for reading .

The surprise lies in the conversations. The model doesn't retain memory between messages: on each turn, it rereads the system instructions, everything that has already been said, and your new message. If on turn k it rereads the previous k − 1 turns, the sum of all the turns results in 1 + 2 + … + (n − 1) = n(n − 1) / 2 , the same sum that, according to the anecdote, Gauss solved as a child. The dominant term grows with the square of the number of turns.

Assumptions: 1,500 token system instructions, 100 token user messages, and 250 token responses, with Claude Sonnet 5.5 list prices (input and output) without caching. Zirve calculation.
ShiftsTokens written in the conversationEntry tokens collectedTimes moreCost with 2,000 conversations per month (USD)
13501,6004.611
51,75011,5006.671
103,50031,7509.1177
207,00098,50014.1494
4014,000337,00024.11,548

A 10-turn conversation uses 3,500 text tokens, but the entry fee is almost 32,000. Increasing the number of turns from 20 to 40 multiplies the entry fee by 3.4. Providers offer prompt caching , which significantly reduces the cost of the identically repeated portion of the context (in Sonnet 5.5, at 5% of the normal entry fee); it doesn't eliminate the Gaussian summation, but it does lower it.

2. How much does it remember: the context window

What we call conversation memory is the context window : the maximum number of tokens the model can read in a single call. In most recent Claude models, this is 1 million tokens; with our rule of 1.3 tokens per word, that's about 750,000 words in Spanish, roughly 1,500 pages. When a conversation exceeds this window, something has to be discarded: the application either truncates the oldest messages or summarizes them. That's why an AI "forgets" what you said at the beginning of a very long conversation.

Why does this limit exist? In a transformer, each token is compared to all previous ones using the attention mechanism. With n tokens, the number of comparisons is 1 + 2 + … + n = n(n + 1) / 2: again, Gaussian elimination. The attention calculation grows with the square of the length, so doubling the context implies about four times more attentional work .

And more context doesn't guarantee better answers. The Lost in the Middle study (Liu et al., TACL 2024) found that models make better use of information at the beginning or end of the context, and that their performance drops when the relevant data is in the middle. Using more recent models, Chroma's Context Rot report (2025) evaluated 18 models and concluded that their performance becomes less reliable as the input increases, even in simple tasks.

3. How quickly it responds: one token at a time

The models generate text one token at a time: each new token depends on all previous ones, so they cannot be written in parallel. The response time is approximated as follows:

Time ≈ time until the first token + (output tokens ÷ generation rate)

The first term increases with what the model has to read before starting; the second, with what it has to write. With an illustrative speed of 50 tokens per second—which varies considerably depending on the model and provider—a response of 650 tokens (about 500 words in Spanish) takes 13 seconds just to write; one of 150 tokens, 3 seconds. And since Spanish uses more tokens per word, the same response takes slightly longer in Spanish than in English.

The right context: how to design an AI that doesn't waste tokens

All three calculations point to the same thing: every token that doesn't contribute costs money, uses memory, and adds waiting time. That's why a well-designed AI doesn't send the model everything it has, but only what it needs to answer that question. In practice:

  • Retrieve instead of pasting everything: if the answer is on page 12 of a 40-page contract, the system searches for the relevant fragments and only those are included in the context. This is what the industry calls RAG (retrieval augmented generation).
  • Summarizing the history: In long conversations, older turns are condensed into a fixed-size summary. The input per turn stops growing, and the quadratic curve becomes linear.
  • Reuse what is repeated: fixed instructions and reference documents go to the beginning of the context to take advantage of the prompt cache.
  • Request short, structured outputs: a JSON with the five fields you need costs a fraction of an explanatory paragraph, and the output is the most expensive token.
  • Choosing the right template for each task: sorting an email doesn't require the same template as writing a report. On Anthropic's mailing list, a Haiku 5.5 entry costs between 20 and 40 times less than a Sonnet 5.5 or Opus 5.5 entry.

Here's an example with numbers. Suppose you extract data from 40-page contracts, each page approximately 500 words long: 20,000 words, or about 26,000 tokens per contract. If you send the entire contract for each of 10 questions, the model reads 260,000 input tokens. If the system retrieves the 3 pages relevant to each question (about 2,000 tokens), it reads 20,000: 13 times less . At Sonnet 5.5 pricing, this is 52 cents per entry versus 4 cents per contract; for 1,000 contracts per month, it's about $520 versus $40. Caching would also reduce the cost of the first scenario, but it doesn't solve the other problem: the model would have to find a needle in a haystack of 26,000 tokens.

To view it with animations

If you want to see how a model converts tokens into numbers and processes them, this video by 3Blue1Brown, a popularizer of mathematics known for his animations, explains step by step how text is broken into tokens, how each token becomes a vector, and how a transformer works.

Watch video: Transformers, the tech behind LLMs, 3Blue1Brown (in English; YouTube allows you to activate Spanish subtitles).

And no, they're not cryptocurrency tokens.

The word is the same; the idea is not. In blockchain, a token is a unit of value or a right recorded on a chain of blocks. In AI, a token is a piece of text and a unit of measurement: it cannot be bought separately, it cannot be exchanged, and it has no value outside of the model.

Frequently Asked Questions

How many tokens does a word have in Spanish?

In our measurement, 1.32 tokens per word averaged with the current OpenAI encoding and 1.57 with the previous one. Short, common words occupy one token; long or infrequent words, two or more.

How many tokens does a page have?

A page of about 500 words in Spanish costs around 650 tokens. A 40-page document costs about 26,000.

Do entry and exit tokens cost the same?

No. Starting prices typically cost several times more. In Anthropic's October 2026 pricing, starting prices are five times higher than entry prices across all their current models.

Conclusion

A token is the unit the AI ​​uses to read, charge for, and measure its memory. Three calculations summarize this: the cost is linear in tokens, a conversation grows exponentially, and the time depends primarily on how much the model writes. Understanding these calculations shifts the question from "Which model should I use?" to "How many tokens does my case actually need?", which is where money is either made or lost.

Are you integrating AI into your operation and unsure of the monthly cost? Tell us about your situation through our contact page or email us at hola@zirve.mx, and we'll help you estimate tokens, costs, and timelines before you invest.

Topics: Artificial intelligence, Tokens, Generative AI, SMEs

See all articles