Every AI feature you've ever shipped or paid for boils down to one HTTP call. Press play and I'll take that call apart with you — the request, the roles, the tokens, the tiers, the meter, the failures, and the key you must never leak. Read along below, or just listen.
Your request — four controls
The JSON that leaves your machine rendered live — nothing is sent
Ch. 1 / The mental model ▶ narrated
Strip away every SDK, framework, and buzzword, and "using AI" is one HTTPS POST: text goes out in a JSON envelope, text comes back in a JSON envelope, and the meter runs on both directions.
Builds a JSON body
One request, one URL
Reads it, writes a reply
Reply + an exact receipt
The server forgets you the instant it answers. No session, no memory, no "it knows me." Whatever it should know rides inside each call.
// this changes everythingYou rent computation per call, priced by how much text goes in and how much comes out. Every response includes the exact counts you were billed for.
// the receipt is built inThe chat website you already use is a pretty front-end doing exactly the call at the top of this page. Once you can read that call, nothing about AI apps is opaque.
// same wire, nicer paintCh. 2 / Anatomy of a request ▶ narrated
As I narrate this chapter, keep the builder at the top of the page in view. Change each control and watch which line of the JSON moves — that mapping is the lesson.
An exact string id naming which model answers. Not a vibe — a spelling. Get it wrong and the API refuses the call. Different ids cost wildly different amounts (chapter 6).
// which brainAn array of turns, each with a role and content. This is the entire world the model sees — if a fact isn't in here (or in system), the model does not know it.
// the whole worldA hard ceiling on the reply's length. It's a stop valve, not a target — the model can finish early, but it can never write past this line. Your cost seatbelt.
// the ceilingStanding instructions that outrank the conversation: who the model is, its rules, its format. Kept separate from user text so instructions don't mix with data.
// the job descriptionCh. 3 / The memory illusion ▶ narrated
A "conversation" with an AI is a magic trick, and you're the magician: every single call, your code sends the entire history again. Click through a three-turn chat and watch the payload grow.
The conversation (what a user sees)
The payload YOUR code sends each call simulated — scripted replies, no network
Ch. 4–12 / Locked
You've heard the setup. The remaining 9 chapters are where The API, Demystified actually gets built — the guardrails, the hands-on builds, the full narrated walkthrough and the end-of-workshop check.
One file. Yours forever. Works offline, in any browser, on any device.