Module 3
Machines That Talk
How chatbots and large language models really work โ from chopping words into tokens and guessing the next word, to the thing almost nobody teaches you: how these AIs charge you money, what the limits are, and how to add up the cost of any chatbot or AI agent. A 20-day journey. By the end you'll build your own BudgetBot.
How to get the most out of this module
This is the module that makes you dangerous โ in a good way. When you use ChatGPT, Claude Code, Cursor, or any AI agent, you'll actually understand what's happening AND what it costs. Do these:
๐ฝ๏ธ Part 1 ยท Text Becomes Machine Food
Words turn into tokens โ and tokens are what you pay for.
The Word-Chopping Machine
Type anything and watch a real tokenizer slice it into tokens โ numbers and emojis get weird.
The Token Price Tag
Your first AI receipt: input tokens vs output tokens, and why output usually costs more.
Guess the Next Word
A real next-word predictor, trained live in your browser. That's all a language model does.
The Context Backpack
The model's memory has a size limit. Pack too much and stuff spills out โ meet the context window.
Chat Gets Pricier Every Turn
Every message re-sends the whole conversation. Watch the cost snowball turn by turn.
๐ฃ๏ธ Part 2 ยท How Talking Machines Generate
Probabilities, creativity dials, and paying attention.
The Creativity Dial
Slide the temperature: safe and boring, or wild and weird. Same model, different vibe.
The Probability Race
Watch tokens race to be picked. Edit the context and the front-runner changes.
Build-a-Bot Personality
Hidden instructions that shape how a bot talks โ meet the system prompt.
Why Bots Make Stuff Up
Ask about a fake planet and watch it answer confidently. Meet hallucination.
The Attention Room
Click a word and see which earlier words it "looks at." The secret behind transformers.
๐ฐ Part 3 ยท Limits, Money & Agent Loops
The part that saves you real money. This is the heart of the module.
The AI Cash Register
The full calculator: paste a prompt, pick a model, get the dollar cost. Your money superpower.
The Long-Chat Snowball
A multi-turn cost simulator. See why 10 chatty messages cost way more than one good one.
The Agent Token Furnace
Watch an AI agent loop โ plan, tool, result, repeat โ and quietly burn tokens each step.
The Speed-Limit Gates
Fire requests and trip the limits โ context window, RPM, TPM, and your budget cap.
Cheap, Fast, Smart: Pick Two
Match the right model to the job. Using a giant model for a tiny task wastes money.
๐ก๏ธ Part 4 ยท Making Chatbots Useful & Safer
Give it real knowledge, defend it, and ship your own.
Give the Bot a Notebook
Look up real facts and feed them in so the bot stops guessing. Meet RAG.
The Sneaky Instruction Trap
Hidden text that hijacks a bot. Learn prompt injection โ and how to defend against it.
Why Bots Are Bad at Math
Ask a language model to multiply big numbers โ then give it a real tool and watch it win.
The Privacy Shredder
What should never go into a prompt. Redact secrets before you hit send.
Build Your BudgetBot
Combine it all: tokenizer + context meter + cost calc + safety, under a strict budget.
Real tools, models & token calculators
You know the ideas AND the pro words now. Here are the real, free tools engineers use to build with language models and to watch their token bill. Most run in a browser or on a laptop.
๐งฐ Try & build with LLMs
- HuggingChat โ free open chatbots beginner
- Ollama โ run LLMs on your own laptop beginner
- transformers.js โ LLMs in the browser pro
๐ข Count tokens & costs
- OpenAI Tokenizer โ see real tokens beginner
- Tiktokenizer โ live token viewer beginner
- tiktoken โ the real tokenizer library pro
๐ท๏ธ Real price pages (check these!)
- Anthropic (Claude) pricing beginner
- OpenAI API pricing beginner
- Google Gemini pricing beginner
๐ค Agents & RAG building blocks
- LangChain โ chains, tools & agents pro
- LlamaIndex โ RAG over your docs pro
- LiteLLM โ track spend across models pro