AI & Automation

LLMs Explained for Operators: Tokens, Context, Hallucination and Cost

Large language models explained for people who run operations: what tokens are, how context windows work, why models invent things, and what really drives cost.

Mauricio Esparza By ·Published ·8 min read
mithub.club
Short answer

A large language model predicts the next piece of text given everything it has been shown. Operators need four things: tokens are the unit of text you pay for, the context window is the model's working memory for one request, hallucination comes from training and scoring that reward guessing, and cost is calls multiplied by tokens multiplied by model tier.

In short

  • A model is not a database. It generates text; it does not look things up unless you give it a tool that does.
  • Tokens are the unit of text you are billed for, both in and out.
  • The context window is working memory for one request. Everything counts toward it, including tool definitions and the answer itself.
  • Hallucination is a predictable consequence of how models are trained and scored, not a glitch.
  • Cost = calls × tokens per call × model tier, multiplied by every retry and loop.

Tokens: the unit you pay in

Text is split into tokens before the model sees it. A token is usually a common word, a word fragment or a punctuation mark.

Google's Gemini documentation gives the most quotable rule of thumb: one token is about four characters, and 100 tokens equal roughly 60 to 80 English words. Anthropic's pricing documentation gives a comparable estimate — approximately four characters or 0.75 words in English — and notes that the exact count varies by language and content type.

Three operator consequences follow:

  1. Your inputs are bigger than they look. A 4-page PDF, a CRM record and a 20-line system prompt add up quickly, and you pay for them on every single call.
  2. Language matters. Because counts vary by language, the same message in two languages can cost noticeably different amounts. If you run multilingual workflows, measure both.
  3. Estimate before you scale. Providers expose token-counting endpoints precisely so you can price a workload before running it across 50,000 records. Use them instead of generic third-party tokenizers, which may not match the model you are actually calling.

The context window: working memory, not memory

The context window is all the text the model can reference while producing one response — including that response. Anthropic's documentation describes it as working memory, explicitly distinguishing it from the data the model was trained on.

Two things surprise people:

Everything counts. Anthropic's docs spell it out: the system prompt, every message in the conversation, tool results, images and documents, plus your tool definitions all count toward the window, and so does the output the model generates. In agentic systems, tool definitions and accumulated tool results are frequently the largest hidden consumers — not the user's question.

More is not better. The same documentation notes that as the token count grows, accuracy and recall degrade, a phenomenon it names context rot. Curating what goes into context is as important as how much space you have.

And the blunt one: the model has no memory of your business. Between requests it retains nothing. Anything it appears to remember was re-sent in that request, retrieved from a store your system maintains, or summarized forward by a compaction step. If your workflow depends on the model "knowing" your pricing rules, those rules have to be in the request, every time — which is also why they cost you tokens, every time.

Practically:

  • Put the instruction close to the data it applies to.
  • Send the three relevant records, not the whole table.
  • When conversations run long, summarize and drop, rather than letting history accumulate.
  • Expect a hard error rather than graceful degradation if the input alone exceeds the window.

Why models make things up

A hallucination is a confident, fluent, wrong answer. It is not the model malfunctioning; it is the model doing exactly what it was optimized to do.

In Why Language Models Hallucinate, Adam Tauman Kalai, Ofir Nachum, Santosh Vempala and Edwin Zhang argue that models hallucinate because training and evaluation procedures reward guessing over acknowledging uncertainty. Their analogy is a student on a difficult exam: guessing scores better than leaving the answer blank, so a system optimized to be a good test-taker learns to guess. They also argue that when incorrect statements cannot be distinguished from facts during pretraining, errors arise from ordinary statistical pressures. Their proposed fix is socio-technical: change the scoring of the benchmarks that dominate leaderboards, so uncertainty is not punished.

You cannot change how the industry scores models. You can change how your workflow scores answers:

  • Ground the answer. Give the model the source data in the request and instruct it to use only that. This is what retrieval does; see RAG for sales teams.
  • Make "unknown" a legal output. If your schema only permits a value, the model will produce one. Add unknown or not_found as an allowed enum value and you will be astonished how often it is the right answer.
  • Constrain the shape. A label from a fixed list can be validated by code. A paragraph cannot.
  • Verify against a system of record. The CRM knows the phone number. The model is guessing at it.
  • Measure. Twenty to fifty hand-labelled real examples tell you your actual error rate. A demo tells you nothing.

And the rule that matters most in operations: never let a model be the only thing standing between a guess and a customer. That is what the human in the loop is for.

What actually drives your bill

Model usage is priced per million tokens, with separate rates for input and output — and output is typically priced several times higher than input. Anthropic's pricing documentation shows that structure clearly, along with two levers worth knowing:

  • Prompt caching. Reusing an identical prompt prefix across calls lets the provider read from cache at a fraction of the standard input price (Anthropic's standard cache-read multiplier is a tenth of base input, with a small premium charged on the write). Caching changes what you pay for those tokens — not whether they count toward the context window.
  • Batch processing. Anthropic's Batch API processes large volumes asynchronously at a 50% discount on both input and output tokens. If a job does not need an answer in the next second, it probably belongs in a batch.

Pricing changes often and varies by provider, so treat the mechanics as stable and the numbers as something to look up. The five things that actually move your bill:

  1. Number of calls per record. This is the one people forget. A five-step chain costs five times a single call, before retries.
  2. Tokens per call. Mostly input: prompts, attached records, tool definitions, conversation history.
  3. Output length. Priced higher. "Write a detailed summary" is a budget decision.
  4. Model tier. The gap between the smallest and largest models in a family is usually a large multiple.
  5. Loops and retries. An uncapped agentic loop is an open invoice. Cap iterations, cap spend per day, alert on anomalies.

A budget worksheet (hypothetical numbers)

Imagine a workflow that processes 10,000 records a month. Each record sends about 2,000 input tokens and gets back about 300 output tokens, in a two-step chain. That is 20,000 calls, 40M input tokens and 6M output tokens a month.

Now imagine a price of $3 per million input tokens and $15 per million output tokens — invented figures, used only to show the shape of the calculation. That is $120 of input and $90 of output: $210 a month. Swap in a tier that costs three times more and you are at $630. Add an evaluator step that runs on every record and you are at roughly $840. Cache the static two-thirds of the prompt and the input line drops substantially.

The lesson is not the number. It is that the four decisions — how many calls, how much context, how long the output, which tier — are yours, and they compound.

MitHub's model tier test

Before choosing a model, answer five questions. If you cannot, you are choosing by reputation.

#QuestionIf the answer is...
1Can I write down what a correct output looks like?No → build the eval set first. Nothing else matters yet.
2Is this classification/extraction, or open-ended reasoning?Classification → start at the smallest tier.
3What is the cost of one wrong answer?High → larger tier plus a human gate, not one or the other.
4How many times per day does it run?Thousands → tier choice dominates your bill; test the cheap one properly.
5Does it need current or private information?Yes → the problem is retrieval and tools, not model size.

Then follow three rules:

  • Start small and move up only on evidence. Run the smallest tier against your eval set. Upgrade when it fails, not when you feel nervous.
  • Make the model a configuration value, not a hardcoded string. Models are replaced constantly. Your workflow should survive a swap.
  • Ignore leaderboard numbers for your decision. Public benchmarks measure generic tasks. Thirty examples of your work are worth more than any published score, and re-running them is how you evaluate a new model in an afternoon.

The operator's glossary

TermWhat it means in practice
TokenA chunk of text, roughly four characters in English. The billing unit.
Context windowEverything the model can see in one request, including its own answer.
System promptStanding instructions sent with every request. Counts as input tokens.
InferenceOne run of the model. One call.
Structured outputA response constrained to a defined shape your code can validate.
Tool / function callThe model asking your system to do something, with arguments.
RAGRetrieving relevant documents and putting them in the request as grounding.
Eval setYour labelled examples. The only honest measure of whether a change helped.
Prompt cachingPaying less for a repeated prompt prefix. Does not free context space.
BatchAsynchronous processing at a discount, for work that can wait.
HallucinationA fluent, confident, wrong output.

Where to go next

This is the floor, not the ceiling. Once the vocabulary is solid, the useful next questions are architectural: how to combine model calls into something reliable, in agentic workflows; when a model belongs in a step at all, in AI agents vs automation; and how to design the whole process around these costs and limits, in AI-first workflows. To apply it to revenue systems with real money attached, start with the Revenue Reverse Engineering faculty.

Frequently asked questions

What is a token?

A chunk of text the model processes. Google's Gemini documentation puts one token at roughly four characters, with 100 tokens equal to about 60 to 80 English words. Counts vary by language and content type.

Does the model remember our previous conversations?

Not by itself. A model only sees what is in the current request. Anything it appears to remember was re-sent in that request, or retrieved from a store your system maintains.

Why does the same prompt give different answers?

Generation is probabilistic, so identical inputs can produce different wording. That is why production steps should return structured, validated outputs rather than free text you parse by hand.

Is a bigger context window always better?

No. Anthropic's documentation notes that accuracy and recall degrade as the token count grows, so curating what goes into context matters as much as how much space there is.

Sources

  1. Understand and count tokens (Gemini API) — Google (accessed 2026-09-17)
  2. Context windows — Anthropic (Claude Developer Platform documentation) (accessed 2026-09-17)
  3. Pricing — Anthropic (Claude Developer Platform documentation) (accessed 2026-09-17)
  4. Why Language Models Hallucinate — Kalai, Nachum, Vempala & Zhang (arXiv:2509.04664) (accessed 2026-09-17)
LLMsAI & AutomationCost Control
Mauricio Esparza
Mauricio EsparzaGTM Systems Lead · Revenue Engineer · Founder of MitHub. Designs and runs revenue systems for multi-location businesses: AI voice campaigns, enrichment, CRM automation and attribution. Founded MitHub to teach the method in the open.

Part of AI & Automation on MitHub.

Keep going

AI & Automation

What Is an AI Agent? LLMs, Tools, Memory and Their Limits

What an AI agent is in plain language: how LLMs use tools in a loop, memory and context, RAG, agentic workflows, human in the loop and where agents fail.

Read · 7 min →mithub.club
AI & Automation

Agentic Workflows: Patterns That Actually Work

The five agentic workflow patterns that work in production — chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer — and when to use none.

Read · 7 min →mithub.club
AI & Automation

What Is AI Automation? A Practical Guide for Revenue Work

AI automation explained simply: rules vs AI-assisted steps, human in the loop, APIs, webhooks and JSON, architecture, process mapping and the real risks.

Read · 10 min →mithub.club
AI & Automation

Human in the Loop: Where People Belong in AI Workflows

How to place humans in AI workflows on purpose: risk tiers, seven approval patterns, the rubber-stamp trap, and written criteria for removing a review gate.

Read · 9 min →mithub.club
AI & Automation

RAG for Sales and Support Teams, Explained Simply

What retrieval-augmented generation is, when a sales or support team should use it instead of a database query, and how to keep the answers correct.

Read · 9 min →mithub.club
AI & Automation

AI Agents vs Automation: How to Choose the Right One

AI agents vs automation: how they differ in control, cost, testing and risk, plus a simple decision grid to choose a workflow, an AI step or a bounded agent.

Read · 6 min →mithub.club