IntegrAuth Academy
Identity, security and practical AI — free, from zero. Byte-sized lessons, real diagrams, hands-on labs, zero fluff. Two programs, each with its own exam and certificate.
English is hard? Your browser can translate this page into Tamil, Telugu, Kannada, Malayalam or Hindi. Tech words stay in English so you learn the real names.
How?
- Chrome on phone: ⋮ menu → Translate
- Chrome on computer: right-click → Translate to …
- Edge: the translate icon in the address bar
Tokens and context windows
Priya's team builds a help bot. The first bill is far higher than they guessed. Your goal: learn what an AI reads, writes and charges for.
🧪 Interactive lab — enable JavaScript to play with this one.
- An AI reads and writes in small pieces called tokens.
- You pay for tokens in and tokens out. Output usually costs more.
- Your chat, files and the answer share one space of fixed size.
- When it is full, old messages drop out. The AI "forgets" them.
Pieces, not words
An AI does not read letters or words. First, a tool cuts your text into pieces. This tool is a tokenizer. Each piece is a token. A common word is often one token. A rare word becomes a few pieces. In English, 100 tokens is often about 75 words. Tamil, Telugu or Hindi text often needs more tokens than the same English. So it can cost more and fill the window sooner.
What you pay for
Everything you send counts as input tokens. That means hidden app rules, tool lists, the chat so far, files and your question. What the AI writes back is output tokens. Prices are per million tokens. Output usually costs several times more.
One space for everything
The model keeps no memory between messages. So the app sends the whole chat each time. It must all fit in one space of fixed size, the context window. You met it in your first AI chat. Your input and the answer share it.
Sam asks for Spanish first. Watch his chat fill the window.
🧪 Interactive lab — enable JavaScript to play with this one.
Go deeper: languages and code
A tokenizer learns its pieces mostly from English text. So other languages are often cut into smaller pieces. A 2023 study found that some languages needed up to 15 times more tokens than English. In October 2026, OpenAI's open-source tiktoken library counted the same sentence, "Hello, please reset my password.", in four languages. Older cl100k_base: English 7 tokens, Hindi 38, Tamil 75, Telugu 82. Newer o200k_base: English 7, Hindi 17, Tamil 24, Telugu 24. Newer tokenizers shrink the gap, but it stays. Code also uses many tokens. It has symbols, spaces and long names.
Each model has its own tokenizer. So the same text can give a different count on another model. Tokens also explain an old trick question. Models used to miscount the r's in "strawberry." They never saw the letters, only the pieces.
Go deeper: the math
Say input costs $3 per million tokens, and output costs $15 per million. These prices are only an example. One request sends 2,000 tokens and gets 500 back.
- Input: 2,000 × $3 ÷ 1,000,000 = $0.006
- Output: 500 × $15 ÷ 1,000,000 = $0.0075
- Total: $0.0135
That is almost nothing once. But at 10,000 requests a day, it is $135 a day. So teams that build with AI watch their token counts.
Why does output cost more? The model reads all your input in one big step. But it writes the answer one token at a time. Each token needs its own trip through the model. So output is slower, and it costs more to serve. Some models "think" before they answer. That thinking counts as output too. See Inside one answer and Cost, limits and caching.
Go deeper: when the window is full
What happens depends on the tool. Through an API, a request that is too big gets an error. An answer that runs out of room stops in the middle of a sentence.
Chat apps often drop the oldest messages. Or they swap them for a short summary. This is called compaction. So a rule from your first message may no longer be in the window. Then the AI does not see it at all.
Good habits:
- Start a new chat for a new task.
- Carry over a short summary, not the whole chat.
- Paste only the parts of a document you need.
- Say your key rules again.
Go deeper: bigger is not better
Window sizes vary a lot. A small model on a laptop may hold a few thousand to tens of thousands of tokens. As of October 2026, several online models hold about a million tokens or more.
But a full window does not help the AI. A 2023 study, Lost in the Middle, tested long inputs. Models did best when the key fact was at the start or the end. They did worse when it was in the middle. Newer models do better, but the advice stays the same. Put your question after a long document. Cut what the task does not need.
Priya's bot sent the whole 40-page travel policy with every question. It also sent the whole chat. Then the team sent only the right sections. The bill dropped, and the answers got better too. See Search by meaning: embeddings and RAG.
In security, a "token" is a pass that proves who you are. In AI, it is a piece of text. Never paste a real password or key into a chat.
Paste text into Tiktokenizer or the Hugging Face Tokenizer Playground. Try English, another language and some code. Compare the counts.