Prompts, context and structured outputs
What goes into the context window, in what order — and getting JSON you can trust back out.
☰
The model only sees what your code packs into one request — so what goes in, in what order, what gets reused, and what shape comes back out are design decisions, not prompt tricks.
+ The whole system in one paragraph− Hide
Every call to a model is a package your backend assembles: instructions, tool definitions, retrieved documents, the conversation so far and the user's question. This page shows how that package is built, where in it facts get lost, how prompt caching reuses its stable front, how to get JSON back that always matches your schema, and how agents keep the package from overflowing.
In this lesson
6 chapters · ~9 min · a quick check in eachEverything is on this page — just scroll down ↓
The whole picture
One request, assembled
Five kinds of content flow into one request, and the model reads all of it. Each box does one job; the flows show assembling a request, a cache hit, a full window and JSON output.
The user asks a question. That's the only part of the request they write.
Your app has one text box. What does the model actually see?
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.
- 2What goes in, in what order
- 3When the window fills up
- 4Prompt caching
- 5Structured outputs
- 6Context engineering for agents