esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

How Do You Estimate the Token Count of a Text?

A quick rule for a rough token count, where it fails, and how to get the closest count from the model provider, explained for your AI interview.

In short

Divide the characters by about four for a rough English estimate, which is fine for planning. For the closest number, use the model provider's own token counter on the full request, because models can split the same text differently.

10 min readBeginnerCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

A quick guess is characters divided by four, because OpenAI says one token is about four English characters. That's good enough for planning. For the most accurate number, I call the provider's token counting endpoint on the whole request, not just my text, because the message structure and tool definitions add tokens too. Anthropic's docs still call that count an estimate, so I check the budget against real traffic after launch. And I recount whenever we change models.

What is a token count, in plain words?

A token is the small piece of text a model reads and writes. A token count is simply how many of those pieces a text makes, and it is not the same as a word count.

Think of a shipping clerk with a parcel. A quick weigh tells you roughly what is inside. A full count means opening the box and checking every item. The quick guess is characters divided by four. The most accurate count comes from the provider's own tokeniser, which splits the text the way that model does.

Why it matters: providers charge for tokens, and every model can only hold so many tokens at once. A support bot that answers 40,000 chats a day needs to know its tokens per chat, or the bill and the context limit both come as a surprise.

Key words

Token
A piece of text the model reads or writes, such as a short word or part of a long one.
Tokeniser
The part that splits text into tokens. Models can use different ones, and some share one.
Context window
The most text a model can work with in one request, counted in tokens.
Counting endpoint
A provider's own API call that returns the token count of a request, without writing an answer.
System prompt
The developer's standing instructions at the top of a request. The user does not see them, but they still use tokens.

Is there a quick rule, and how good is it?

Yes. OpenAI's rough rule for English text is that one token is about four characters, or three-quarters of a word. So 100 tokens are about 75 words. It works well for a first guess on plain English.

Two ways to count a text

Your text

What you plan to send

Quick guess

Characters / 4

Good for planning only

Provider's count

Provider's counter

Same split the model uses

Rough plan

Size and rough cost

Budget that holds

Set from the provider's count

  1. 1Divide the characters by about four.
  2. 2Send the whole request to the provider's count call.
  3. 3The guess gives a rough plan and a rough cost.
  4. 4The provider's count sets the budget you ship with.
Two ways in. The quick guess is fine for a plan. The provider's own count sets the budget, because it splits the text the way that model does.

The rule breaks on other languages, unusual spellings and capitals, because a word can split into different tokens depending on its spelling, capitalisation and the text around it.

  • “These are estimates, not exact counts.”

    OpenAI

Tip

A rule of thumb tells you the size. Use the provider's count for the bill.

How do you get the most accurate count?

  1. 1

    Count the whole request

    Send the system prompt, tools, messages and images to the counter, not just your text. A plain-text count, which means counting only the words you typed, can leave parts of the request out.

  2. 2

    Use the model you will ship

    Models can split text differently, so recount on the exact model name in your code.

  3. 3

    Check real usage after each call

    An OpenAI Responses reply reports input_tokens, the input count that request used. Compare it with your estimate and fix the budget if the gap grows.

  4. 4

    Use a library only for plain text

    For plain text on your own machine, OpenAI's tiktoken library is a tokeniser built for its models. It is not a count of a full chat request.

  • “The token count is an estimate.”

    Anthropic

  • “The same input text produces approximately 30 percent more tokens than on earlier models.”

    Anthropic

Anthropic's counter is free to use, but it has requests per minute limits, so do not recount the same request over and over.

What does one real support request look like?

Take a made-up support bot at a mid-size bank. It answers questions about card fees and refunds. Each chat sends three big pieces of text: policy snippets it looked up, the customer's message and the chat so far. The system prompt and the tool definitions add more on top.

What one support request sends

Text in the request

Policy snippets

Found by the search step

Customer message

Changes on every turn

Chat so far

Grows each turn, so cost rises

Added to the request

Tool definitions

Schemas the model may call

Request as sent

Adds roles and structure

Full input count

Checked against the budget

  1. 1Snippets the search step found go in.
  2. 2The customer's words go in.
  3. 3Earlier turns go in again, so they add to every request.
  4. 4Tool schemas count too.
  5. 5The provider counts the whole request.
Several pieces of text join one request, and the provider counts all of them. A plain-text count of the customer's message misses the structure and the tools, so the count can come out higher.

Using the rule, the three pieces come to about 1,950 tokens. The made-up count from the provider came to 2,310, which is 18 percent more. At 40,000 chats a day, the budget is 92,400,000 input tokens. The guess gives 78,000,000.

Python
# A support bot's token budget, with made-up numbers. The rule of thumb is only a first guess.
import math

CHARS_PER_TOKEN = 4  # OpenAI's rough rule for English text

# Made-up sizes, in characters, for one support chat.
pieces = {
    "policy snippets": 4800,
    "customer message": 600,
    "chat history": 2400,
}

def guess_tokens(chars):
    return math.ceil(chars / CHARS_PER_TOKEN)

total = 0
for name, chars in pieces.items():
    tokens = guess_tokens(chars)
    total += tokens
    print(f"{name}: about {tokens} tokens")

# Made-up: what a provider's count call might return for this request.
provider_count = 2310
print(f"rule of thumb total: {total}")
print(f"provider count: {provider_count}, {round((provider_count - total) / total * 100)}% more than the guess")
chats_per_day = 40000
print(f"daily input at the provider count: {provider_count * chats_per_day:,} tokens")

Output

policy snippets: about 1200 tokens
customer message: about 150 tokens
chat history: about 600 tokens
rule of thumb total: 1950
provider count: 2310, 18% more than the guess
daily input at the provider count: 92,400,000 tokens

So the rule is for planning, and the provider's count sets the budget. The guess is cheap, and it helps you see the shape of the cost before you spend on a count.

How would you keep the budget honest when models change?

  1. 1

    Keep a fixed set of test requests

    Pick 20 real, anonymised requests from the support queue and keep them unchanged.

  2. 2

    Count them on every model change

    Run the counter on the same 20 requests before the switch and after it, and compare the totals.

  3. 3

    Alert when the numbers shift

    If the average input per chat moves by more than 10 percent, the budget and the context limit get a review before release.

What does the interviewer want to hear?

A strong answer covers

  • A quick rule: about four characters per token for English.
  • Where the rule fails: other languages, odd spelling and capitals.
  • The most accurate count comes from the provider's counter, on the full request.
  • Recount after a model change, since models can use different tokenisers.
  • Budget with the provider's count, and check real usage after launch.

Common traps

  • Trap"One word is one token, so count the words."

    BetterTokens and words differ. 100 tokens are about 75 English words, and other languages shift that.

  • Trap"The guess is good enough for the bill."

    BetterUse the guess to plan. Set the budget from the provider's count on the full request.

  • Trap"The old count still holds after we switch models."

    BetterClaude 4.7 and later models use a newer tokeniser, and the same input text can come out about 30 percent higher. Recount.

Can you spot the mistake?

Spot the mistake

A teammate wrote four lines for a billing report. Which line should never set a bill?

Quick check

A chatbot moves to a newer model family. What should you do with the token budget?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q003What is a token, and why not whole words?11 min
  2. Q004How do tokenizers like BPE, WordPiece and SentencePiece work?11 min
  3. Q005Why do token counts differ across languages and models?10 min
  4. Q030Why are input and output tokens priced differently?11 min
  5. Q105How do you budget tokens for chat history?10 min
  6. Q324How do you estimate token cost for a feature?11 min

Learn it in depth

Last updated on 26 November 2026

Budgeting tokens for an AI feature that is live?

I design and build AI products and agents, including the token budget and the limits behind them. Book a short call and tell me what your feature sends and how many people will use it.