What Is a Token in AI? Meaning, Costs & Context Windows

What Is a Token in AI? Meaning, Costs & Context Windows

What is a token in AI? A token is the smallest unit of text that an AI model reads and writes.

It can be a whole word, part of a word, a punctuation mark, or a single character.

Every message you send to a chatbot gets split into tokens before the model sees it. Every answer gets built back up from tokens, one at a time.

Tokens decide what a model can remember, how fast it answers, and what it costs.

Tokens are explained here from the ground up: how tokenization works, how many words a token holds, what tokens cost across providers, and how to use fewer of them without losing quality.

A token is the basic unit an AI model processes. Models never see words or letters directly.

They see token IDs, look up a learned vector for each one, and predict the next token in the sequence.

Table of Contents

What Is a Token in AI? The Short Answer

A token is a chunk of text from a fixed vocabulary. Common words usually become one token each. Rare words split into familiar pieces. Punctuation, spaces, and line breaks count as tokens too.

Think of tokens as the pieces of a puzzle. A model cannot work with whole sentences, so a tokenizer cuts each sentence into pieces it already knows. The model then works with those pieces only.

The most useful rule of thumb comes from OpenAI guidance. One token is about four characters of English text, or about three quarters of a word. One hundred tokens hold roughly 75 words.

That rule is only an average. Code, numbers, and other languages break it often.

A long URL, a block of code, or a sentence in Japanese can use far more tokens per word than plain English prose.

Token vs Word vs Character vs Byte

Four units get confused constantly, so here they are side by side. Each one measures something different, and only tokens matter to the model itself.

Unit What it measures Example Who uses it
Token A chunk of text from the model vocabulary “unhappiness” becomes “un” plus “happiness” AI models, APIs, billing
Word A unit of human language separated by spaces “unhappiness” is one word People, writers, editors
Character A single letter, digit, or symbol “unhappiness” has 11 characters Text editors, forms
Byte A unit of digital storage, 8 bits “unhappiness” is 11 bytes in UTF-8 Computers, files, networks

A token sits between a word and a character. It is bigger than a letter and smaller than most sentences. That middle size is what makes it useful for models.

One more distinction matters for anyone who searches this topic. AI tokens are not crypto tokens. Crypto tokens are digital assets traded on blockchains. AI tokens are units of text inside language models.

Login tokens are different again. An API token or authentication token is a secret key that proves who you are.

It has nothing to do with how a model reads text, even though the word is the same.

How Tokenization Works

What Is a Token in AI? Meaning, Costs & Context Windows

Tokenization is the process that turns raw text into tokens. It runs before the model sees anything, on every message, every time. Without it, a model could not read at all.

First, the tokenizer splits the input into pieces from its fixed vocabulary. Then it maps each piece to an integer ID.

The model looks up a learned vector for each ID and works with those numbers.

When the model answers, the process runs in reverse. It produces token IDs one at a time, and a detokenizer turns them back into readable text.

You never see the numbers, only the words they become.

From Text to Token IDs

Each token in a vocabulary has exactly one integer ID. The sentence “Hello world” might become two IDs, one for “Hello” and one for ” world” with its leading space attached.

One tokenizer measured the question “Why do cats purr?” as six tokens with IDs 13903, 621, 28854, 275, 1057, and 30. The model never sees the letters. It sees only those six numbers.

Spaces belong to the next word in most modern tokenizers. The token is ” do”, not “do”. A word at the start of a sentence and the same word mid-sentence can be different tokens.

What an Embedding Is and Why It Matters

An embedding is a list of numbers that captures a token meaning. Each token ID maps to a dense vector, often 512, 1,024, or more dimensions long. Similar tokens get similar vectors.

Embeddings are how a model knows that “king” and “queen” are related, or that “run” and “running” share meaning. The numbers place related tokens close together in a high-dimensional space.

Without embeddings, token IDs would be arbitrary labels. With them, the model can reason about relationships between words, because the geometry of the vectors reflects the structure of language.

Byte Pair Encoding, the Method Most Models Use

Byte pair encoding, or BPE, is the most widely used tokenization method in modern language models.

GPT models use it, and it was adapted for neural machine translation by Sennrich and colleagues in a 2016 paper.

BPE starts with single characters and counts every adjacent pair across a huge amount of text. It merges the most frequent pair into a new token, then repeats until the vocabulary reaches its target size.

After enough merges, frequent words become single tokens while rare words stay as a few pieces. Modern tokenizers run BPE on bytes, not characters, so any text can always be represented, even emoji.

Byte-level BPE means there is no such thing as an unknown word. There are only words that cost more tokens, because rare text falls back to small pieces or individual bytes.

WordPiece, SentencePiece, and Unigram Compared

BPE is not the only method. Google introduced WordPiece for BERT, and SentencePiece came later for models like T5. Unigram is a probabilistic method often paired with SentencePiece.

Method How it builds vocabulary Used by Example split
BPE Merges the most frequent adjacent pairs GPT models, Llama, CLIP “tokenization” becomes “token” plus “ization”
WordPiece Merges pairs that maximize training-data likelihood BERT, DistilBERT, Electra “unhappy” becomes “un” plus “##happy”
SentencePiece Works directly on raw text, no pre-splitting T5, XLNet, ALBERT “Hello world” becomes “▁Hello” plus “▁world”
Unigram Starts large and prunes tokens that matter least Often with SentencePiece Chooses the most likely segmentation

WordPiece marks continuation pieces with a “##” prefix, so “##happy” means the piece continues a word. SentencePiece keeps the space as a special symbol, usually shown as “▁”, which marks a word boundary.

Unigram works in the opposite direction from BPE. It starts with a large vocabulary and removes tokens, while BPE starts small and merges. Both end with a fixed vocabulary of frequent pieces.

Every model family has its own tokenizer, so the same sentence gives different counts in GPT, Claude, Llama, or Gemini. Never assume one model count applies to another.

Special Tokens

Special tokens are markers for the structure of a sequence. They carry no word meaning. They tell the model where text starts, where it ends, and where padding fills the gaps.

Common special tokens include start-of-text, end-of-text, and padding tokens. BERT uses a “[CLS]” token whose final embedding serves classification, and a “[SEP]” token that separates two segments.

System prompts and tool calls use special tokens too. They mark the boundary between your message, the model instructions, and any tool output, so the model knows which part is which.

Token Examples You Can Check Yourself

What Is a Token in AI? Meaning, Costs & Context Windows

The fastest way to understand tokens is to watch real text split apart. These examples use OpenAI tokenizers, and the exact splits vary by model, but the pattern holds everywhere.

Common Words, Rare Words, and Brand Names

Common words usually survive as one token. “Love”, “pizza”, “the”, and “surprisingly” each take a single token in most English tokenizers, because they appear constantly in training data.

Rare words split into familiar pieces. “Anthropic” becomes “Anthrop” plus “ic”. “Tokenization” becomes “token” plus “ization”. The model has no single entry for the rare word, so it spells it out.

Brand names behave the same way. “ChatGPT” splits into “Chat”, “G”, and “PT” in older tokenizers, because the vocabulary was built before the name was common. Newer vocabularies may hold it as fewer pieces.

Very long words split into many pieces. “Antidisestablishmentarianism” becomes six tokens: “anti”, “dis”, “estab”, “lishment”, “arian”, and “ism”. Each piece is a chunk the model has seen before.

The pattern is simple and worth remembering. Common words cost one token, rare words cost several. That is why technical writing costs more tokens per word than casual prose.

Numbers, Code, and Punctuation

Numbers split in ways that surprise people. The year “2024” is one token, because it is common. The number “17,394” becomes three tokens: “17”, “,”, and “394”. The decimal “0.000001” becomes three tokens as well.

Code is more token-dense than prose. The line “print(hello)” becomes four tokens: “print”, “(“, “hello”, and “)”. A short Python function of five lines can use about 45 tokens.

An English explanation of the same function takes about 30 tokens. Code costs more per line than prose, because symbols, indentation, and short identifiers each consume tokens.

Punctuation is always its own token. A period, a comma, and a question mark each count separately. Spaces attach to the following word, so ” is” is one token that includes its leading space.

Emoji and Special Characters

Emoji count as tokens too, and they can be expensive. A rocket emoji is one token in some tokenizers and several in others, depending on how the vocabulary was built.

Unusual characters behave the same way. Accented letters, currency symbols, and rare punctuation often break words into small pieces, which raises the token count of the surrounding text.

URLs are a good test case. A long address like a blog post URL can use 14 tokens, because slashes, dots, and hyphens each split the text into pieces.

Short links cost fewer tokens than long ones.

How Many Words Is a Token?

What Is a Token in AI? Meaning, Costs & Context Windows

People ask this question more than any other about tokens. The honest answer has two parts: a handy average, and the reasons that average often fails.

The 4-Character Rule of Thumb

One token is about four characters, or about three quarters of a word, in English. One hundred tokens hold about 75 words. One thousand tokens hold about 750 words.

OpenAI publishes this rule in its own guidance, and every major guide repeats it. It works well for ordinary English prose, which is what most people paste into chatbots.

One measurement of a large English glossary found 4.65 characters per token instead of 4, or about 1.29 tokens per word.

The average depends on the text, so treat the rule as an estimate, not a promise.

Two quick conversions help in practice. Divide the character count by four to estimate tokens, or multiply the word count by 1.33. Both give a rough answer in seconds.

Everyday Documents in Tokens

Token counts become concrete when attached to familiar documents. These figures use the 0.75-words-per-token rule for ordinary English prose.

Document Approximate words Approximate tokens
Tweet, 280 characters 45 to 55 60 to 75
Short email 100 130 to 140
One paragraph 100 130 to 140
Blog post 1,500 About 2,000
Short story 5,000 About 6,500
300-page novel 90,000 About 120,000
Harry Potter series About 1,100,000 About 1,100,000
5,000-line codebase Not counted in words 15,000 to 25,000

A one-million-token context window holds roughly 750,000 words of English prose. That is several long books, or a very large codebase, inside a single conversation.

Code breaks the table. A 5,000-line codebase can use 15,000 to 25,000 tokens before the model does anything, because code is denser than prose and every symbol counts.

Why the Rule Breaks for Code and Other Languages

The 4-character rule assumes ordinary English. Three things break it: code, numbers, and non-English text. Each one pushes the token count up for the same amount of meaning.

Code uses symbols, indentation, and short names that tokenizers split aggressively. A function that reads as five lines to a programmer can cost 45 tokens, while its plain-English description costs 30.

Numbers fragment badly. A price like “17,394” or a decimal like “0.000001” splits into three tokens, so tables full of figures cost far more tokens than the same information written as prose.

Other languages cost more because tokenizers learn from training data, and most training data is English.

The same greeting takes 6 tokens in English, 7 in Spanish, 18 in Japanese, and 15 in Arabic in one published comparison.

Tokens in Images, Audio, and Video

Modern models handle more than text, and every other input becomes tokens too. The mechanism differs by media type, but the principle holds: larger, more complex files take more tokens.

Image Tokens and Patch Size

Vision models split an image into fixed-size patches, and each patch becomes one token. The Vision Transformer introduced this idea in a 2021 paper, using 16 by 16 pixel patches.

A 224 by 224 pixel image becomes 196 tokens at that patch size. Doubling the side to 448 pixels yields 784 tokens, four times as many, because the patch count grows with area.

Published estimates for image token counts vary by model and resolution.

One guide puts a 512 by 512 image at roughly 256 to 512 tokens, a 1024 by 1024 image at 1,000 to 1,500, and a 4K image at 6,000 to 8,000.

Also Read this  Is Janitor AI Down? Three Different Downs and the 60-Second Triage

Another guide gives point figures instead: about 256 tokens for 512 by 512, about 1,024 for 1024 by 1024, and about 8,000 for 4K. Treat both as ranges, and check the model documentation before budgeting.

The practical lesson is simple. Resize images before sending them to an AI.

A compressed 512 by 512 version usually works as well as the full-resolution original for describing a photo or reading a chart, at a fraction of the token cost.

Audio Tokens per Second

Audio becomes tokens based on duration. One published guide estimates about 25 to 30 audio tokens per second, so a 60-second clip uses roughly 1,500 to 1,800 tokens.

Another estimate puts 30 seconds of audio at about 750 tokens, two minutes at about 3,000, and one hour at about 90,000. The two estimates agree closely, which makes audio the most predictable media type.

A one-hour podcast sent for transcription and summary consumes roughly 90,000 input tokens before the model writes a single word back. Long audio is one of the fastest ways to fill a context window.

Video Tokens and Why They Compound

Video compounds image and audio tokens together. A 10-second clip at one frame per second becomes 10 frames of image tokens plus the audio tokens for those 10 seconds.

At about 500 tokens per frame, that short clip already uses about 5,000 image tokens before audio. Longer clips, higher frame rates, and higher resolutions multiply the count quickly.

For any application that processes media, count tokens at the media level before the bills arrive.

A batch of 10 product photos can use 5,000 image tokens plus the text prompt, and that cost repeats on every batch.

What Is a Context Window?

A context window is the maximum number of tokens a model can process in one request. It holds everything: the system prompt, the conversation history, any files, the tool definitions, and the answer being written.

Early models had tiny windows. GPT-3.5 handled 4,096 tokens, or about 3,000 words. GPT-2 managed about 1,024 tokens, and GPT-3 raised that to 2,048.

Modern frontier models offer far more. Several current models list windows of 1 million tokens or more, enough for a full-length book, a large codebase, or months of conversation history in one request.

What Fills the Window

Everything the model sees counts against the window. The hidden system prompt can use hundreds or thousands of tokens. Every earlier message counts, both yours and the model replies.

Files, pasted documents, and tool outputs count too. Images and PDFs convert to tokens and join the same budget. The answer itself needs room inside the window as well.

That last point catches people out. If a model has a 128,000-token window and your prompt uses 126,000 tokens, only about 2,000 tokens remain for the answer, no matter how long the answer should be.

What Happens When the Window Fills Up

When a conversation grows past the window, the oldest messages start falling off. The model literally cannot see them anymore, and from its perspective they never happened.

That is why a chatbot seems to forget instructions from the start of a long session. It has not malfunctioned. The information has simply scrolled out of the window it can read.

Different products handle overflow differently. Some return an error, some silently drop the oldest messages, and some summarize the earlier conversation and carry the summary forward instead.

Three habits prevent the problem. Summarize key decisions periodically and start a fresh conversation with that summary. Keep new topics in new conversations.

Repeat critical constraints near the current message instead of relying on something said fifteen messages ago.

Context Windows by Model

Context windows differ widely by model and by date, so each figure below carries its source. Never merge figures from different dates into one number.

Model Context window What it holds Source and date
GPT-3.5 (2023) 4,096 tokens About 3,000 words All guides agree
GPT-5.6 Luna 128,000 tokens About 96,000 words HackerNoon guide, Aug 2026
GPT-6 Luna 1,050,000 tokens About 750,000 words OpenAI pricing page, Oct 2026
Claude Sonnet 5 200,000 tokens About 150,000 words HackerNoon guide, Aug 2026
Claude Fable 5 1,000,000 tokens Multiple novels HackerNoon guide, Aug 2026
Gemini 3.1 Pro 1,000,000 tokens About 750,000 words HackerNoon guide, Aug 2026
Gemini 2.5 Pro 1,000,000 tokens A large codebase ByteByteGo, Aug 2025

The jump from 4,096 tokens in 2023 to 1,000,000 tokens in 2026 is remarkable.

Most conversations never approach the limit of a modern model, but the limit still shapes long coding sessions and big document work.

One caution applies to every large window. Just because a window holds 1 million tokens does not mean you should use all of it.

Cost scales with tokens used, and model quality can degrade when relevant facts hide in a sea of noise.

Context Windows by Subscription Plan

Chatbot plans do not give every user the same window. The model may support 1 million tokens through the API, while the chat product on a free plan offers far less.

OpenAI pricing page figures reported in 2026 put the ChatGPT Free plan at 27,000 tokens in instant mode. The Go and Plus plans list 54,000 tokens in instant mode and 256,000 in reasoning mode.

The Pro plan lists 128,000 in instant mode and 400,000 in reasoning mode.

Older secondary guides give different numbers, with free plans at 8,000 to 32,000 tokens and Plus at 128,000.

Plan limits change without announcement, so check the provider pricing page on the day you rely on a figure.

Claude plans work differently. The Free plan costs nothing and carries usage limits that reset every five hours and every week, with context up to 1 million tokens on all plans.

Paid tiers raise the message caps rather than the window itself.

Free tiers also cap message counts. One mid-2026 comparison reports about 10 messages per five hours on the ChatGPT free flagship model, after which the product drops to a smaller model until the window resets.

Knowing your plan window matters more than knowing the model maximum. A free user with a 27,000-token window hits the ceiling after roughly 20,000 words of total conversation, including every reply the model already wrote.

Input Tokens vs Output Tokens

Every API call has two token flows, and they are not priced the same. Understanding the split is the key to understanding any AI bill.

Input tokens are everything you send in. Your question, the conversation history, any documents you paste, any system instructions, any tool outputs, and any images all count as input.

Output tokens are everything the model sends back. The response you read, the reasoning it does first, and any tool calls it makes all count as output, and output costs more.

Why Output Costs More

Reading input is fast because the model processes many tokens in parallel. Modern hardware handles that efficiently, so input tokens are cheap to run.

Generating output is slow because the model produces one token at a time. Each new token depends on everything that came before, so the process cannot be fully parallelized.

That asymmetry shows up in every price list.

Output tokens typically cost 3 to 6 times more than input tokens, and one analysis puts the most common ratio at exactly 5 to 1 across major providers.

The practical rule follows directly. Reducing output length saves more money than reducing input length. Asking for bullet points instead of paragraphs, or JSON instead of prose, cuts the expensive side of the bill.

Thinking Tokens: The Hidden Multiplier

Reasoning models generate an internal monologue before they answer, working through the problem step by step. Those internal steps are called thinking tokens, or reasoning tokens.

Thinking tokens are invisible to you, because you usually see only a short summary or the final answer. They are billed as output tokens at full output price, and they can dwarf the answer itself.

One worked example shows a 15-token question producing 1,800 thinking tokens and a 180-token answer. The total output billed was 1,980 tokens, not 180, an 11-fold increase over the visible reply.

Another example shows a 15-token question producing 2,000 thinking tokens and a 15-token answer. The total billed was 2,015 output tokens, or 134 times the cost of the same question without reasoning.

Reasoning earns its cost on genuinely hard problems: complex maths, multi-step logic, ambiguous debugging. For simple questions, reasoning tokens are pure waste, and the same answer arrives for far less.

The rule is simple. Match the tool to the problem. Hard problem, reasoning mode. Simple task, standard mode. Never use a sledgehammer to hang a picture frame.

Cached Tokens and Prompt Caching

Cached tokens are input tokens the provider has already processed and stored, so they cost less on the next call.

Prompt caching reuses a fixed system prompt or a large document instead of processing it again.

Discounts differ by provider. Anthropic offers about 90 percent off cached input tokens, so a cached token costs about 10 percent of the normal price. OpenAI offers about 50 percent off cached prompt tokens.

Google Gemini offers context caching for contexts over 32,000 tokens, with discounts up to 75 percent in published guides. Each provider sets its own rules, so check the vendor documentation before relying on a figure.

Caching helps most when the same long context repeats across many calls. A customer service bot with a fixed 5,000-token instructions block, or a document question-answering system with a fixed knowledge base, gains the most.

One worked example shows a 3,000-token system prompt called 1,000 times a day. Without caching it costs about 3 dollars a day at one provider rate.

With caching it costs about 30 cents a day, a 90 percent saving after the first call.

How Much Do AI Tokens Cost?

AI services bill by the token, usually per million tokens, with separate rates for input, cached input, and output. Prices vary enormously by model, and they change often.

Price per Million Tokens by Provider

Each row below carries its source and date. Prices from different dates must never be merged into one number, because the same model name can carry different prices in different months.

Model Input per 1M Output per 1M Source and date
Amazon Nova Micro $0.035 $0.14 aipricing.guru, Aug 15, 2026
DeepSeek V4 Flash $0.14 $0.28 aipricing.guru, Aug 2026
Llama 4 Maverick $0.15 $0.60 aipricing.guru, Aug 15, 2026
Gemini 3.7 Flash $0.30 $2.50 aipricing.guru, Aug 15, 2026
Claude Haiku 4.5 $1.00 $5.00 aipricing.guru, Aug 2026
GPT-5.6 Luna $1.00 $6.00 aipricing.guru, Aug 2026
Claude Sonnet 5 $2.00 $10.00 aipricing.guru, Aug 2026
Gemini 3.1 Pro $2.00 $12.00 aipricing.guru, Aug 15, 2026
GPT-5.6 Sol $5.00 $30.00 aipricing.guru, Aug 15, 2026
Claude Opus 5 $5.00 $25.00 aipricing.guru, Aug 2026
Claude Fable 5 $10.00 $50.00 aipricing.guru, Aug 2026
GPT-6 Luna $0.10 $0.50 OpenAI pricing page, Oct 17, 2026
GPT-6.1 Sol $2.00 $10.00 OpenAI pricing page, Oct 17, 2026
GPT-6 Astra $10.00 $50.00 OpenAI pricing page, Oct 17, 2026

The spread is extreme. The cheapest capable production model in the August 2026 table costs $0.035 per million input tokens, while the most expensive costs $10, nearly 300 times more.

Model names change fast, and the same family name can mean different models in different months.

Always verify the current price on the vendor pricing page before budgeting, and never trust a price table without a date.

A single short exchange costs almost nothing.

A 50-token message plus a 200-token reply costs about a thousandth of a cent on a cheap model, and about a tenth of a cent on an expensive one.

Volume changes everything. The same exchange repeated 1,000 times a day becomes a real monthly bill, and an agent reading 100,000 tokens of context per call becomes a serious budget line.

What a Real Task Costs

Take a customer support chatbot handling 1,000 conversations a day. Each conversation uses about 600 input tokens and 200 output tokens on average.

On a cheap model at $1 per million input and $5 per million output, that workload costs about $18 a month for input and $30 for output, or $48 a month in total.

The same workload on a premium model at $5 and $25 costs about $240 a month.

The difference between the cheapest capable model and the most expensive one for the same workload is about $576 a year versus $2,880 a year.

Whether the premium model is worth five times more depends entirely on whether the task needs that level of capability.

One builder learned this the hard way with an agent that read 200 customer emails per ticket.

Each email used about 500 tokens, so every ticket consumed 100,000 input tokens before any work began, and the monthly bill reached $340 instead of the expected $50.

Building with AI means token costs are part of the business model, not an afterthought.

Anyone planning to earn from AI tools should budget tokens the same way they budget hosting.

A practical starting point is a guide to making money with AI that covers real methods and their costs.

Batch Discounts and Long-Context Surcharges

Two pricing details rarely appear in guides, and both change the math. Batch inference sends many prompts at once, asynchronously, at a discount of typically 50 percent off.

It is slower, but much cheaper for work that is not time-sensitive.

Long context carries a surcharge on some providers.

OpenAI pricing page figures reported in October 2026 charge a higher rate once a request goes over 272,000 input tokens: double for input and 1.5 times for output on the GPT-6 models.

Batch pricing also appears in published OpenAI figures, with batch input at half the standard rate and batch output at half as well.

A workload that can wait is often half the price of one that cannot.

Why Token Prices Keep Falling

Token prices have fallen dramatically. In early 2024, GPT-4 level capability cost roughly $30 per million input tokens.

By August 2026, comparable capability cost $1 to $3 per million, and budget models cost $0.03 to $0.15.

That is an 80 to 200-fold reduction in about two and a half years, according to published pricing comparisons.

Applications that cost hundreds of dollars a day to run in 2024 now cost a few dollars a day.

One comparison makes the shift concrete. Analysing 100,000 support tickets a month would have cost about $9,000 a month for input tokens alone at 2024 prices.

At 2026 budget-model prices, the same workload costs about $14 a month.

Google scale shows the other side of the trend.

Google processes 3.2 quadrillion tokens per month, according to chief executive Sundar Pichai at the company I/O keynote in May 2026, a figure that shows how central tokens have become to the whole industry.

How to Count Tokens Before You Send Them

The most powerful cost control is counting tokens before you send them. Guessing leads to surprise bills, while measuring takes seconds and removes the guesswork.

The Free Online Tokenizer

OpenAI offers a free online tokenizer tool that shows exactly how text splits into tokens. Paste any text, and it highlights each token in a different colour while showing the total count.

Spend ten minutes pasting different types of text: casual conversation, code, legal documents, and non-English text. You will quickly develop a gut sense for what is cheap and what is expensive.

The tool is the fastest way to build intuition. It answers the question “how many tokens is this?” instantly, before you spend anything, and it works without signing in.

Counting With tiktoken in Python

Developers can count tokens in code with tiktoken, the open-source library from OpenAI. Install it with pip, pick the encoding for the model, and count the tokens in any string.

A short function returns the token count for a given text and model. The same sentence measured with different encodings gives different counts, because each model family uses its own tokenizer.

One example counts a short business letter at 52 tokens with an OpenAI encoding and 54 tokens with the Claude counter.

Small differences like that are normal, and they are why you should count with the tokenizer that matches the model you call.

Counting With the Anthropic API

Anthropic offers an official token counting endpoint that does not charge for inference. Send the messages and the system prompt, and the API returns the input token count before you make the real call.

Also Read this  How Does AI Use Water? The Real Numbers, Per Prompt to 2030

Google offers similar counting through the Gemini API, with a dedicated tokens page that explains token types, multimodal token counts, and pricing. Each provider documents its own method, and each one differs slightly.

Never use one provider count as an exact figure for another provider. Use each count as an estimate for other models, and expect differences of 10 to 20 percent when you switch families.

Token Counting Tools Compared

Tool Vendor Cost What it counts
OpenAI Tokenizer OpenAI Free Text split into tokens with a visual highlight
tiktoken OpenAI Free, open source Token counts in Python for OpenAI encodings
Anthropic count_tokens Anthropic Free, no inference charge Input tokens for messages, system prompt, and tools
Gemini tokens page Google Free Token types, multimodal counts, and pricing
Hugging Face tokenizers Hugging Face Free, open source Token counts for open models and custom vocabularies

Each tool matches its own vendor best.

The OpenAI tokenizer is the quickest check for GPT models, the Anthropic endpoint is the accurate check for Claude, and the Gemini page is the accurate check for Gemini models.

How to Use Fewer Tokens Without Losing Quality

Seven strategies cut token costs without hurting results. They work for chatbots, API applications, and everyday prompting, and they compound at scale.

1. Ask for the Format You Actually Need

The most direct way to reduce output tokens is to specify the output format. Ask for three pros and three cons in one sentence each, instead of asking for a general explanation.

The first version might generate 500 tokens. The second might generate 80, with the same information. That is about 84 percent fewer output tokens for the same answer.

Ask for JSON instead of prose when you need data. Ask for bullet points instead of paragraphs when you need a list. Ask for one sentence when one sentence is enough.

2. Compress Your System Prompt

System prompts run on every single API call, so a bloated system prompt is a tax on every conversation. Review it critically and remove anything the model could infer.

One example cuts an 85-token system prompt to 24 tokens by removing polite filler and redundant instructions. That saves 61 tokens per call, or 610,000 tokens a day at 10,000 calls a day.

Small prompt optimizations compound enormously at scale. A few dozen tokens saved per call becomes millions of tokens saved per month on a busy application.

3. Do Not Send What the Model Does Not Need

Before including something in a prompt, ask whether the model actually needs it to answer correctly. A product description does not need the entire company history behind it.

A debugging question does not need every file in the repository. A translation does not need the surrounding document. Send what is needed and leave out everything else.

4. Summarise Instead of Dumping Documents

When you need context from a long document, do not paste the whole thing. Summarise it first, then ask the model to work from the summary.

A 10,000-token document costs 10,000 input tokens on every question. A 400-token summary costs 400 tokens per question after a single summarisation pass, and the savings repeat on every follow-up.

5. Use Caching for Repeated Content

If a long system prompt, a large document, or a fixed context appears in many calls, enable prompt caching. Anthropic offers about 90 percent off cached input, and OpenAI offers about 50 percent off.

Caching requires one extra parameter in the API call. The first call pays full price for the cached content, and every later call pays the discounted rate for the same content.

6. Start Fresh Conversations for New Topics

Every message in a conversation history adds to the input token count of every later call. A conversation with 50 exchanges can add 8,000 tokens of history to each new message.

When you start a genuinely new topic, start a new conversation. The history from the old conversation is not helping, and it is costing tokens on every turn.

7. Use the Right Model for the Task

The cheapest capable model for a task is always the best choice when capability is comparable. Simple classification, extraction, and translation work fine on cheap models.

Save premium models for genuinely hard problems that need deep reasoning. Routing simple tasks to cheap models can cut costs by 60 to 80 percent, according to published routing examples.

Build a habit of asking whether a task actually needs the most powerful model, or whether that is just the default you always reach for. The answer is often the cheaper one.

Tokens and Language Fairness

Tokenizers learn from training data, and most training data is English. That fact creates a real cost gap for people who write in other languages, and it is rarely discussed.

Why the Same Sentence Costs More in Some Languages

The same greeting takes 6 tokens in English and 7 in Spanish in one published comparison. The same question takes 18 tokens in Japanese and 15 in Arabic, or about three times the English cost.

A developer example makes the gap concrete. The question “Why do cats purr?” takes 6 tokens in English, 8 in French, and 15 in Yoruba, or 2.5 times the English cost for the same meaning.

Accented characters often break words into small pieces. In Yoruba, accented letters like ó, ò, and ń split words apart, so a short sentence becomes many tokens and fills the context window faster.

For a developer building for non-English users, that means higher API bills, slower answers, and less room in the context window for the same conversation.

Cost estimates based on English testing will be significantly lower than real production costs.

What Builders Should Do About It

Measure token counts in the languages your users actually write, not only in English. A budget built on English counts will understate costs for every other language your product serves.

Choose models with better multilingual tokenizers when your audience writes in many languages. Some models prioritize Chinese, Spanish, and French in training, and their tokenizers reflect that choice.

Keep prompts short in high-cost languages, and prefer structured output that the model can produce in fewer tokens. Small savings per message become large savings across thousands of users.

Token Security: Denial-of-Tokens and Denial-of-Wallet

Tokens are not only a cost and a limit. They are also an attack surface, and government cyber guidance now treats token abuse as a security risk for organizations.

How the Attacks Work

A denial-of-tokens attack exhausts an organization token allocation on purpose. Attackers generate excessive AI usage through automated prompts, abuse of publicly accessible AI interfaces, or manipulation of workflows that process unusually large volumes of data.

The result is delays, degraded performance, failed requests, or loss of access to AI capabilities. Organizations that depend on AI for mission-critical functions are particularly affected when no contingency exists.

A denial-of-wallet attack aims to cause financial harm instead.

Attackers exploit consumption-based pricing by prompting tools with complex inputs that require long outputs, or by creating loops where a tool feeds its own response back into itself.

Both attacks work because AI pricing is usage-based. Every token an attacker consumes is a token the organization pays for, or a token a legitimate user cannot use.

Alerts, Quotas, and Governance That Stop Them

The Canadian Centre for Cyber Security recommends progressive alerts as usage approaches a quota.

An information alert at 70 percent of the quota, a warning at 80 percent, and a critical alert at 90 percent give teams time to act.

Organizations should separate token allocations into tiers. Mission-critical functions like cyber defence and incident response get the highest priority, essential business processes come next, and everyday productivity use sits last.

Monitoring matters as much as limits.

Unusual increases in token consumption can signal data exfiltration, similar to how abnormal bandwidth spikes can signal unauthorized transfers, so token telemetry belongs in security monitoring alongside identity and API logs.

Other defences include multi-provider architectures that reduce dependence on one vendor, AI gateways that enforce quotas and guardrails, and human authorization for consequential AI-driven actions.

Smaller or locally run models can also handle simpler tasks at lower risk.

Tokenization Quirks That Explain Strange AI Behaviour

Many odd model behaviours trace back to tokenization, not to reasoning. When a model fails at something that looks easy, the token split is often the reason.

Why Models Struggle With Spelling and Counting Letters

A model sees subword tokens, not individual letters, so tasks that depend on single letters are harder than they look.

Counting the letters in a word or reversing it requires the model to reason about pieces it never saw as letters.

Misspellings make the problem worse. A tokenizer breaks a misspelled word into unfamiliar or rarely seen token combinations, which disrupts the patterns the model learned from frequent sequences.

That is why a model can write fluent essays yet fail to count the letters in “strawberry”. The essay uses familiar token patterns, while the counting task needs letter-level information the tokens hide.

Why 3.11 vs 3.9 Confuses a Model

Language models often fail at simple comparisons like asking whether 3.11 or 3.9 is bigger. Tokenization explains the failure, because the model never sees the numbers as numbers.

The figure 3.11 splits into tokens like “3”, “.”, and “11”, while 3.9 splits into “3”, “.”, and “9”. To the model, these are symbolic fragments, not floating-point values.

The model is not comparing values.

It is pattern-matching based on how those token fragments appeared in training data, which is why the answer can be wrong even when the maths is trivial for a person.

Modern models often answer correctly anyway, through extra training data, system instructions, or tools that do the maths for them. The token split is still the reason the question is hard in the first place.

Why Typos Cost More Tokens

A typo turns a familiar word into unfamiliar pieces. The tokenizer cannot match the misspelled word to a single token, so it falls back to smaller chunks, and each chunk costs a token.

Copying and pasting code or foreign text can eat through a token budget faster than expected for the same reason. Unusual formatting, rare characters, and unfamiliar names all fragment into more tokens.

Clean text is cheaper text. Fixing typos, removing redundant formatting, and trimming pasted content before sending it saves tokens and helps the model understand the input better.

A Short History of Tokenization

Tokenization predates modern chatbots by a decade. The methods in use today come from machine translation research, and their history explains why they work the way they do.

Byte pair encoding began as a data compression algorithm, then Sennrich and colleagues adapted it for neural machine translation in a 2016 paper on rare words.

The idea was simple: split rare words into frequent pieces instead of treating them as unknown.

Google introduced WordPiece for its translation and BERT models around the same period. WordPiece chooses merges by likelihood rather than raw frequency, which gives slightly different splits for the same text.

SentencePiece arrived later from Google, designed to work directly on raw text without language-specific pre-splitting. It became the standard choice for models like T5, XLNet, and ALBERT, and it handles languages without spaces between words.

The transformer architecture itself arrived in the 2017 paper “Attention Is All You Need”. Transformers read token sequences, so tokenization became the front door of every large language model built since.

Vocabulary sizes grew with the models. BERT used 30,522 tokens, GPT-2 used 50,257, and later models grew far larger: Llama 3 holds 128,256 tokens, and Gemma 3 holds about 262,000.

Bigger vocabularies mean fewer splits for rare words, at the cost of larger embedding tables.

Visual tokens came next. The Vision Transformer paper in 2021 showed that an image split into patches could be treated as a token sequence, which opened the same machinery to images, audio, and video.

FAQs

What is a token in AI in simple terms?

A token is the smallest piece of text an AI model works with. It can be a whole word, part of a word, or a punctuation mark. Models read and write tokens, never words directly.

Is a token the same as a word?

No. A token is roughly three quarters of a word on average, but common words take one token while rare words split into several.

A token is a unit from the model vocabulary, not a unit of human language.

How many words is 1,000 tokens?

About 750 words of ordinary English prose. The rule comes from OpenAI guidance: one token holds about four characters, or about three quarters of a word, so 1,000 tokens cover roughly 750 words.

How many tokens is one word?

About 1.33 tokens per word on average for English prose. Common words usually take one token, while longer or rarer words take two or more, and code or numbers take more still.

Is 1 token 4 characters?

Approximately, for ordinary English text. One measurement of a large English glossary found 4.65 characters per token instead, so treat four characters as a handy estimate rather than an exact conversion.

What is tokenization in AI?

Tokenization is the process that splits raw text into tokens. A tokenizer cuts input into pieces from a fixed vocabulary, maps each piece to an integer ID, and hands those IDs to the model.

How does tokenization work step by step?

First the tokenizer splits the text into known pieces. Then it maps each piece to a token ID.

The model looks up an embedding vector for each ID, processes the vectors, and produces new token IDs as its answer.

What is a token ID?

A token ID is the integer that represents one token in the model vocabulary. Each token has exactly one ID, and the model works with those numbers instead of letters or words.

What is an embedding in AI?

An embedding is a list of numbers that captures what a token means. Each token ID maps to a dense vector, often hundreds of dimensions long, and similar tokens get similar vectors.

What is byte pair encoding (BPE)?

BPE is a tokenization method that merges the most frequent adjacent character pairs until the vocabulary reaches its target size. GPT models use it, and Sennrich and colleagues adapted it for neural translation in 2016.

What is the difference between BPE and WordPiece?

BPE merges pairs by frequency, while WordPiece merges pairs that maximize the likelihood of the training data. WordPiece also marks continuation pieces with a “##” prefix, so “##happy” means the piece continues a word.

What is a context window?

A context window is the maximum number of tokens a model can process in one request. It holds the system prompt, the conversation history, any files, and the answer being written, all counted together.

How big is the context window in ChatGPT?

It depends on the plan.

OpenAI pricing page figures reported in 2026 put Free at 27,000 tokens in instant mode, Go and Plus at 54,000 instant and 256,000 reasoning, and Pro at 128,000 instant and 400,000 reasoning.

How big is the context window in Claude?

Claude models offer context up to 1 million tokens on all plans, including the Free plan.

Paid tiers raise the message caps rather than the window, and the full Free versus paid comparison is covered in a guide to whether Claude AI is free and what its limits are.

What happens when the context window fills up?

The oldest messages fall out of the window, and the model can no longer see them.

Some products return an error, some drop old messages silently, and some summarize the earlier conversation and carry the summary forward.

Why does ChatGPT forget what I said earlier?

It has not forgotten in the human sense. The tokens for your early messages have scrolled out of the context window, so the model cannot see them anymore. Summarizing and starting fresh fixes it.

What is the difference between input tokens and output tokens?

Input tokens are everything you send in, and output tokens are everything the model sends back. Input includes your message, the history, and any files. Output includes the reply, the reasoning, and any tool calls.

Why do output tokens cost more than input tokens?

Reading input happens in parallel, while generating output happens one token at a time.

Each output token depends on everything before it, so generation is slower and more expensive, typically 3 to 6 times the input price.

What are thinking tokens?

Thinking tokens are the internal reasoning steps a model generates before answering.

They are invisible to you, because you usually see only a short summary or the final answer, but they shape the quality of hard answers.

Are thinking tokens billed?

Yes. Thinking tokens are billed as output tokens at full output price, and they can dwarf the visible answer. One example billed 1,800 thinking tokens for a 180-token reply, an 11-fold increase.

What are cached tokens?

Cached tokens are input tokens a provider has already processed and stored, so they cost less on the next call.

Anthropic offers about 90 percent off cached input, OpenAI offers about 50 percent off, and Gemini offers up to 75 percent for large contexts.

How much does 1 million tokens cost?

It depends on the model.

August 2026 pricing figures put the cheapest capable models at $0.035 to $0.14 per million input tokens.

Mid-tier models cost $1 to $2, and premium models cost $5 to $10, with output costing 3 to 6 times more.

How do I count tokens before sending a prompt?

Use the free OpenAI Tokenizer tool for a quick visual check, count with the tiktoken library in Python for OpenAI models, or use the Anthropic counting endpoint for Claude.

Each tool matches its own vendor best.

Do images use tokens?

Yes. Vision models split an image into patches, and each patch becomes a token.

A 224 by 224 pixel image becomes 196 tokens, and a 4K image can use roughly 6,000 to 8,000 tokens depending on the model.

Is an AI token the same as a crypto token?

No. An AI token is a unit of text inside a language model. A crypto token is a digital asset traded on a blockchain. The two share a word and nothing else.

What happens when you run out of tokens mid-response?

The model stops where the limit falls, so the answer ends abruptly. Some products cut off the beginning of the conversation instead, and some summarize earlier messages to make room for the reply.

Conclusion

What is a token in AI? It is the unit everything in a language model is measured in: what the model reads, what it writes, what it costs, and what it can remember.

Once you understand tokens, pricing, context windows, and model behaviour all make sense.

Three facts carry the most weight. Tokens are the unit of everything, so the token count decides cost, speed, and memory.

Context windows fill up, so long conversations lose their start unless you summarize and start fresh.

Output costs more than input, so asking for shorter, structured answers is the fastest way to cut any AI bill.

The cheapest way to learn is to try it. Paste a paragraph into the free OpenAI Tokenizer, then paste the same paragraph in another language, then paste a block of code.

Five minutes of watching text split into tokens teaches more than any definition, and the next time a bill surprises you, you will know exactly where to look.