Structured Output
also called JSON mode, Schema-constrained output
Making the model return data your code can parse.
Constraining output to a schema — JSON, a specific set of enum values — either by prompt, by a JSON mode, or by grammar-constrained decoding that makes invalid output impossible.
For anything programmatic, use schema enforcement rather than polite requests. "Please return valid JSON" fails a small percentage of the time; that percentage is a production incident.
The distinction that matters in production is between requesting a shape and enforcing it. A schema constraint makes invalid output impossible, whereas asking politely leaves a small failure rate — and a small failure rate multiplied by daily volume is a recurring incident rather than a rare one.
Stopping the weekly parse failure
An integration fails roughly once a week on malformed JSON.
A one-in-a-thousand failure looks harmless in testing and produces an alert every few days in production. Move to a schema-constrained mode and the class of failure disappears; the remaining errors become transport errors, which are retryable.
Constraining rather than describing
Classification output must be one of a fixed set of labels.
Declare the enum rather than listing the labels in prose. The model cannot invent a ninth category, which removes an entire downstream branch — the code that handled the invalid label — along with the bug reports it generated.
- docsControlled generation ↗
Constraining generation to a supplied schema for extraction, classification and agent steps — distinct from merely asking for JSON politely.
- docsFunction calling ↗
The application-managed tool cycle spelled out: define the function with a JSON Schema, receive the call, execute it yourself, return the output.
Function Calling · Tool use
The model-provider feature that makes structured tool calls reliable.
Few-shot · In-context examples
Show a handful of examples and let the model pattern-match.
Tool Call
The model asking for a specific function with specific arguments.
Temperature
The dial between predictable and creative.