← Build AI Apps with Real APIs

Lesson 3 of 8

Structured outputs and tool use

Lesson 3 of 8 · Build AI Apps with Real APIs

In this lesson. Get JSON you can trust instead of a paragraph you have to parse.

What you will learn

  • Schemas and validation
  • Failing closed on bad JSON
  • A single tool-call round trip

Walkthrough

Products break when the model returns a poem instead of a schema. You will request structured output, validate it, and fail closed when the shape is wrong. Then you will sketch one tool call: the model chooses a function, your code runs it, and the result comes back. That loop is how apps do work instead of only chatting.

Work through the ideas in order. After each point, pause and connect it to a task you already do — a document, a workflow, or a feature you own. The goal of Build AI Apps with Real APIs is usable skill, not a pile of notes.

If something is unclear, rewrite it in your own words before you continue. Teaching the step back to yourself is the fastest way to see gaps.

Practice

Define a JSON schema for one feature and reject an invalid model response in code or pseudocode.

Keep the first attempt small. A finished example you can reuse beats a perfect plan you never run.

Check your understanding

  • Can you explain the goal of this lesson in one sentence to a teammate?
  • Where would you apply “Schemas and validation” in your own work this week?
  • What would you change on a second pass of the practice?

Next. Continue to the following lesson when the practice has a real artifact, even a rough one.