HeyMark
Content

Blog

What are tokens in AI, how much text is a token, and how are they billed?

9 min read

A token is the unit an AI model splits text into so it can process it: it can be a whole word, part of a word, a single character or a punctuation mark. That’s how OpenAI’s help article on tokens defines it. Model APIs bill by the token: the ones the model reads (input) and the ones it writes (output), each at its own price per million. For a sense of size, Google says that on its Gemini models a token is about 4 characters. OpenAI gives the same figure for English text, where 100 tokens is about 75 words, and notes that other languages can have a different relationship between characters, words and tokens.

An example: how many tokens it takes to reply to a comment

Fictional example: the bakery, the texts and the sizes are made up. Miga is a bakery that built an assistant on a model’s API to reply to comments on its posts. This comment comes in, about 100 characters long:

Do you have gluten-free bread? And if I order a cake for Saturday, can I pick it up in the morning?

The assistant replies with about 200 characters:

Hi! We don’t make gluten-free bread yet, sorry. Cakes need 48 hours’ notice: if you DM us today, you can pick yours up on Saturday from 9:00 at the shop. Want me to send you the flavors?

To write that, the model didn’t read just the comment. It also read Miga’s instructions: its tone, its hours, what it does and doesn’t do, about 20,000 characters in all. At 4 characters per token, the rough count looks like this:

Part Size Approximate tokens
The brand’s instructions (input) 20,000 characters 5,000
The comment (input) 100 characters 25
The reply (output) 200 characters 50
The reasoning beforehand (output, not shown) Not shown 400, an assumption

The reply the customer reads is the smallest part of the bill. The model rereads the 5,000 tokens of instructions with every comment, and if it reasons before answering, those tokens nobody sees are billed too. You can’t know the number of reasoning tokens in advance: the 400 in the table is an assumption for the example. The API reports the real number in its response, along with the input and output counts.

Input, output and reasoning tokens

OpenAI’s help article sorts tokens by role, and that’s the split you’ll see on pricing pages:

  • Input tokens. What you hand the model in each request: your instructions, the conversation so far, any documents you attach and the new message. Images are counted in tokens too: on Gemini, an image up to 384 pixels on each side counts as 258 tokens, and a larger one is split into 768 by 768 pixel tiles that count 258 each, according to Google’s tokens page. If the model uses tools, their names, descriptions and schemas are also billed as input, according to Anthropic’s pricing page.
  • Output tokens. What the model generates. On both models in the table further down, they cost five times as much as input.
  • Reasoning tokens. Models that “think” before answering generate internal text that doesn’t appear in the reply. OpenAI writes that they aren’t visible as answer text, but they count toward output usage and are billed as output tokens. Gemini’s pricing page puts it in the price label itself: “Output price (including thinking tokens).” Anthropic, in its extended thinking documentation, says the response reports how many of the billed output tokens were internal reasoning.
  • Cached input tokens. Input tokens reused from an earlier request. OpenAI notes that their price can differ from regular input, and on Google’s and Anthropic’s pricing pages it’s lower.

What they cost: the formula and a worked example

Prices are listed per million tokens, so the math for one request is:

cost = (input tokens × input price + output tokens × output price) ÷ 1,000,000

Reasoning tokens are added to output. These are the prices for two models, in US dollars, as listed on December 1, 2026:

Model Input Output (includes reasoning) Cached input
Gemini 4 Carbon, Standard tier, from December 1, 2026 $4 $20 $0.20
Claude Sonnet 5.5 $2 $10 $0.10

Sources: Gemini’s pricing page and Anthropic’s. For Claude, the cached column is the price of reading from the cache; writing to it costs more than regular input (1.25 times, for the 5-minute cache). Prices change: Gemini 4 Carbon’s doubled on December 1, since through November 30 it was $2 for input and $10 for output.

On Gemini 4 Carbon, each of Miga’s replies costs this (still the fictional example):

Item Calculation Cost
Input 5,025 tokens × $4 ÷ 1,000,000 $0.0201
Visible reply 50 tokens × $20 ÷ 1,000,000 $0.0010
Reasoning 400 tokens × $20 ÷ 1,000,000 $0.0080
Total per reply $0.0291

A thousand replies a month would come to about $29. Two things stand out in that table: what weighs most is what the model rereads for every comment, and the reasoning nobody sees costs eight times as much as the reply that gets posted.

If the cache hits, the math changes. The 5,000 tokens of instructions would be billed at $0.20 per million ($0.0010), the comment at the regular price ($0.0001) and the output the same ($0.0090): about $0.0101 per reply, around $10 per thousand. But Google warns that its implicit caching is opportunistic and doesn’t guarantee savings. The conditions are in the section on saving tokens, below.

The same text doesn't produce the same tokens on every model

According to Anthropic, how many tokens a text produces depends on the model’s tokenizer, the language and the type of content. Its models from Claude Opus 4.7 onward produce approximately 30% more tokens than earlier ones for the same text. That’s why comparing price per million isn’t enough: OpenAI warns that a lower price per million tokens doesn’t necessarily produce a lower total cost. To compare two models, count the same request on each.

Why an agent uses more tokens than a single reply

An AI agent works in steps: it decides what to do, uses a tool, reads the result and keeps going. Each step is a new request, and each one bills the input that travels again. According to Anthropic’s pricing page:

  • Tools add fixed tokens. On top of each tool’s name, description and schema, turning on tool use adds a system prompt: 286 tokens on Claude Sonnet 5.5 and Claude Opus 5.5 (with tool_choice set to auto or none).
  • Results stay in the conversation. Web search results count as input tokens while the model keeps searching and in later turns as well.
  • The history gets sent again. Caching exists precisely so the same instructions, documents or conversation history aren’t reprocessed on every request.

The difference between an agent and a chatbot is covered in what an AI agent is and how it differs from a chatbot. A concrete case of per-token billing in messaging is Meta’s agent for WhatsApp, covered in what Meta Business Agent is and how much it costs.

How to save tokens

What the OpenAI, Anthropic and Google guides say, from simplest to most technical:

  1. Trim what repeats. OpenAI recommends shortening or rephrasing the prompt and removing unnecessary or repeated context. In the example, every 1,000 characters you cut from the instructions is about 250 fewer tokens on every comment.
  2. Don’t send a whole document when a summary or a chunk will do. OpenAI suggests summarizing or preprocessing text before you send it, and splitting large inputs. If your knowledge base is large, the technique that looks up only the relevant passages is covered in what RAG is in AI.
  3. Put the fixed part first, so the cache can work. On Gemini, implicit caching is on by default from Gemini 2.5 onward, but it needs at least 4,096 input tokens on Gemini 4 and Gemini 3. Google recommends keeping static content at the top and variable content at the end, and sending requests that share the same beginning close together in time. On Anthropic, prompt caching is turned on in the request; according to its pricing page, the 5-minute cache pays off after the first read.
  4. Control length and reasoning. On Claude, max_tokens is the hard ceiling on total output, and at a low effort level the model may skip reasoning on easy questions, according to Anthropic’s thinking documentation. Replying to a comment rarely needs maximum effort.
  5. Pick the model for the task. On its pricing page, Anthropic suggests Haiku for simple tasks, Sonnet for most production workloads and Opus for the most complex reasoning. OpenAI recommends comparing models on representative tasks, for the reason in the box above.
  6. Batch what isn’t urgent. Anthropic takes 50% off input and output with its Batch API, and on Gemini 4 Carbon the batch price is half the Standard one ($2 for input and $10 for output per million).
  7. Count before you send. OpenAI offers the Tokenizer, the tiktoken library and an input token counting API that, according to its help article, is free. Anthropic’s token counting is free too, and returns an estimate that can differ slightly from actual usage.

If what you’re pricing is a whole chatbot for WhatsApp or Instagram, tokens are only one of the layers: the others are in how much an AI chatbot costs.

Plan your next post in HeyMark.

Keep the idea, review the draft with your team, and see how it performed in the accounts you connected.