Skip to content
Module
AI

Structured outputs

Structured outputs are model responses that follow a format defined in advance, typically JSON matching a schema, instead of free text. Providers offer several mechanisms: instructions in the prompt, a JSON mode that guarantees syntactically valid JSON, function calling, and schema-constrained generation that guarantees the response matches a given JSON Schema. Code can then read the output and an interface can display it without fragile parsing.

Why it matters for a PM

As soon as an AI feature feeds a screen, a database or another system, free text becomes a liability: a missing field or an extra sentence breaks the flow. The PM specifies the output contract: which fields exist, their types and allowed values, what the model returns when it is unsure, and how the product behaves when the response is refused or cut short.

Example

A feature that extracts expense data from receipts asks the model for a JSON object with merchant, date, amount, currency and category. When the date is unreadable, the schema allows null, and the interface asks the user to fill it in rather than storing a date the model guessed.

Key points

  • A schema guarantees shape, not truth: a perfectly valid JSON can still contain a wrong value.
  • Enums and explicit null values give the model a legitimate way to say “unknown” instead of inventing.
  • Business rules, such as a delivery date that cannot be in the past or line items that must add up to the total, are checked in code after generation.
  • The contract is versioned like an API, because changing a field can break the consumers downstream.

Common mistakes

  • Relying on a prompt that says “answer in JSON” and discovering in production that it sometimes doesn't.
  • Making every field required, which pushes the model to fill gaps with guesses.
  • Ignoring refusals and responses truncated by the output limit.
  • Changing the schema without rerunning the robustness cases.

Go further with Module

The courses and lessons that cover this concept: