AI engineering · 11 of 42

Structured Outputs

Make the response match a schema

Scroll

Make the response match a schema

Free-form prose is fine for a person to read and miserable for code to consume. Structured outputs constrain the model so its response conforms to a schema you declared: known field names, known types, every time.

That removes an entire class of glue code — no regex, no partial parses, no branch that only breaks when the model gets chatty.

The critical caveat is easy to miss. A schema controls the shape, not the truth. Perfectly valid JSON can carry a wrong category, an invented identifier or an impossible priority. Validate the business rules after parsing, exactly as you would for any input arriving from outside your system.

Interface
A SHAPE THE CALLING CODE CAN RELY ON classify this incident prompt the model schema: category, priority, requires_human fields { "category": "network", "priority": "high", "requires_human": true } Valid JSON every time means no regex, no half-parsed prose, and no branch that only fires when the model gets chatty. But a schema constrains the shape, not the truth. That JSON can be perfectly valid and the category still wrong.
A schema constraining the model's output so the calling code gets known fields and types.