Topic 49

APIs and AI

Next Steps

Every workplace in 2026 has an AI story, and almost nobody in the meeting can say what happens technically when the assistant answers. You can. Underneath the spectacle it is the thing you have been reading about for eleven chapters: a program sends an authenticated request to somebody else's server and reads what comes back.

The companies at the center of that story are model providers. A model, here, is a program trained on enormous amounts of text that produces text in response to text; the provider runs it on their machines and rents access to it. The way they rent it is an API. Software POSTs to an address with a JSON body holding the words to work on and a few settings, and the server answers with JSON holding the generated text. A key identifies the caller. A rate limit caps the pace. An error table explains the refusals. There is no fifth ingredient.

Three layers of an AI feature, and the two you now understand
The AI feature you see
a button in a document, a chat box, a summary that appears
The app that wraps it
assembles the request, sends it, decides what to do with the answer
POST to the model API
key in a header, JSON in, JSON out, rate limits, and a bill per use

The Model Behind a Key

What a model provider sells is exactly the shape this book taught. The request is a POST, because it carries a body: the text to work on, plus settings such as which model to use and how long the answer may be. The response is JSON with the generated text inside it, and next to that, a count of how much was consumed.

That count is the bill. Providers meter by units of text called tokens, which are roughly word fragments, and they charge for the text going in as well as the text coming back. This is Chapter 1's idea of an API as a product with users, support and rules, taken to its most literal form: the meter runs on every request, in both directions, and the invoice is the sum of the counts.

Every AI Feature Is a Request

The writing helper in a document editor, the summarize button in an email client, the support bot on a shop's website: each one is an ordinary application that assembles a request, sends it to a model API, and renders what returns. That is the same construction Chapter 1 described when it pointed out that a weather widget and a card payment are somebody else's API showing through the surface of an app you trust.

Which means these features fail the way APIs fail, and you can now reason about them instead of shrugging. A feature that stopped working for everyone at once looks a lot like a refused credential — a 401 if the key was rotated or revoked, a billing refusal if an expired card took the account's credit with it. A feature that works in the morning and gets slow or sullen at the busiest hour of the afternoon looks like a 429, and AI rate limits are the most talked-about limits in software as of 2026. A feature that hangs and then apologizes is a timeout, and a provider having a bad day is a 5xx. Chapter 7's triage applies to all of it without modification, including the part where you ask whose side the problem is on before you start guessing.

Assistants Are Consumers Too

Here is the newer turn, and the reason this page sits in a beginner's book about APIs at all. Assistants are increasingly built to make API calls themselves: to look up an order, book a slot, file a ticket. When one does, it is a client like any other. It reads a description of what an API offers, sends a request to a real endpoint, and gets back a status code and a body.

The description it reads is often the OpenAPI file from Chapter 6, the machine-readable contract that also generated those try-it-out documentation pages. That file was always meant for programs to read; an assistant is simply a newer kind of program reading it. Nothing about the contract changed to accommodate it.

So every rule of citizenship in this book applies to your automated colleagues, word for word. The key an assistant uses should be scoped to what it actually needs, exactly as Vera's was scoped to reading stations. Its pace counts against the same rate limit as yours. Its retries can double-book a bike as surely as a human's impatient second POST could, which is why Chapter 7 spent a page on which requests may be repeated. And somebody still has to read the docs, choose the scopes, set the budget, and check afterwards what was actually done in their name. The assistant moved the typing. It did not move the understanding.

Where This Goes Next

Two doors, both on this shelf, both natural from here. Working with models as a user — how to ask well, how to verify what comes back, what happens to what you send, and what the request under the chat box actually contains — is its own book: Working with LLMs from Zero, whose Chapter 7 you are now over-prepared for, because it is about the API you have just spent a course learning to read.

Building things that call models in a loop, decide what to do next, and act through APIs is the following rung: Agentic AI from Scratch. It assumes precisely what you now have, which is why it was never the right first book and is a reasonable second or third one.

Common Confusions
  • "AI infrastructure must be some new kind of computing, beyond APIs." The computing that trains a model is genuinely its own field. The part where you reach one is HTTP, JSON, keys and quotas: deliberately boring plumbing under spectacular cargo. The boringness is precisely why it reached the whole world so fast.
  • "AI features fail mysteriously." They fail with status codes. A refused key, an exhausted limit, a timeout, a provider outage: the same four suspects Chapter 7 lined up, in the same order, answering to the same question of whose side the problem is on.
  • "If assistants can call APIs, my API knowledge is about to be worthless." The opposite. Somebody has to read the documentation, scope the key, set the budget, and audit what the assistant did with it. Those are the jobs this book trained you for, and there are now more of them, not fewer.
Why It Matters
  • Connecting the AI wave to eleven chapters of plumbing makes you conversant in the most-discussed technology of the decade from the side almost nobody in the room actually understands. That is a rare and useful position in a meeting.
  • When an AI feature misbehaves at work, you can now ask the question that shortens the conversation: is this our key, our pace, our request, or their server? Everyone else in the room is still saying that the AI is being weird today.

Knowledge Check

What does a model provider's API actually meter and bill for?

  • The number of separate requests the app sends
  • The amount of text going in and coming back
  • The seconds the provider's machines were busy
  • The number of keys the customer has created

An AI feature at work suddenly slows down and starts refusing requests every afternoon at the busiest hour. What is the most reasonable first suspicion?

  • The model has become less accurate under load
  • The key has expired and needs to be reissued
  • A rate limit is being reached at peak use
  • The provider changed its documented parameters

An assistant is set up to call your company's API on your behalf. What does that change about the rules?

  • Assistants are given more generous limits by servers
  • Scopes stop mattering once a program is calling
  • Automated retries are safe because they are automated
  • Nothing: the same keys, limits and retry rules apply

You got correct