The architecture of an AI app
Every piece between a user's question and a reliable answer: API, orchestration, retrieval, tools, the model gateway, streaming, evals and observability.
☰
An AI app isn't one model call: it's a backend that finds the right context, lets the model use tools, streams the answer, survives a provider going down — and measures every step.
+ The whole system in one paragraph− Hide
The model is the smallest part. Around it sits an ordinary backend with a few new jobs: finding the right information to show the model, letting it use your tools, handling a provider that fails, and measuring every step. This page builds the picture one piece at a time — start with the simplest version that works and add a piece only when it earns its place.
In this lesson
4 chapters · ~9 min · a quick check in eachEverything is on this page — just scroll down ↓
New to this? Warm up first+ optional
Words you'll meet
You'll meet these words on every page of this topic. Skim them now and come back whenever one shows up.
ⓘ Details & sources− Hide details
The terms, in plain words.
What it must do — and how well
Yellow notes are what the app must do; blue ones are how well. A demo needs little more than a prompt. Production needs all of them, and each one adds a box to the architecture.
The whole system
What the model actually sees
Every call, your code packs one window: instructions, found documents, the chat and the question. What doesn't fit is invisible — so most of an AI app is deciding what goes in.
Build it up, one piece at a time
The full architecture has eleven boxes. You never build them all at once — each one answers a problem the previous version couldn't.
ⓘ Details & sources− Hide details
Start at step 1. Move on only when something real forces you to.[1]
4 steps. Follow the flow one step at a time — what happens first, and what comes next.
One question, end to end
Follow one question in time order. Retrieval happens before the model is called, and the answer streams back in small pieces.
6 steps. Follow the flow one step at a time — what happens first, and what comes next.
The user asks a question. The API checks who they are and that they're within their limits.
You're starting a new AI feature. According to this page, what should version 1 be?
Pick one — or just keep scrolling, it's not graded.
Keep going — it's free
Create your free account to unlock the rest of this lesson, keep your progress and pick up right where you left off.
- 2Retrieval
- 3Tools & agents
- 4Production