Skip to content
BENIBIX Learn

Structured Output (LLM)

AI🛠️ Working with AIOutput Control

Also known as Structured Outputs, Schema-Constrained Output

The model's answer must fit a set shape, like JSON with set fields.

Think of it like

Think of it like a form with boxes. The answer has to go in the right boxes.

Example

Lucy's app reads receipts. She asks for JSON with a shop, a date and a total. Every reply has those three fields, so her code can save them straight to a database.

Why it matters

It is what lets a program use a model's answer safely. Free text is hard for code to read.

Definition

Structured output makes a model's answer follow a fixed shape, most often JSON that matches a schema you give. A schema lists the fields, their types and which ones are needed. Many model APIs can enforce it, so the reply always fits. That lets a program read the answer with no guessing. Without it, a model may add chatty text or drop a field, and the program breaks.

Example code

json
{
  "shop": "Corner Bakery",
  "date": "2026-03-14",
  "total": 12.40
}
The reply fits the shape the app asked for, so code can read each field.
Free text needs a person to read it. Output in a set shape can go straight into a program.

Common mistake

Checking only that the reply is valid JSON. The fields can still hold wrong values, so check those too.

Key takeaways

  1. 1
    A fixed shape. Fields set in advance.
  2. 2
    Enforced by the API. Replies always fit.
  3. 3
    Code can read it. No guessing.

Compare

Learn it properly