Knowledge tree
On this page

Structured Outputs

How schema-constrained generation changes model output, and where validation and authorization still belong.
Updated 6 Oct 2026

A valid JSON value can still be useless to an application. {"file":"src/app.ts","line":"12"} parses, but line is not an integer. There are several ways to request and check a response’s shape:

Four different mechanisms

MechanismValid JSONSchema adherenceWhen errors surface
Ask for JSON in the promptNot guaranteedNot guaranteedDuring parsing or validation
JSON modeFor an accepted complete responseNoWhen validating the value
Schema-constrained generationFor an accepted complete response, within the supported subsetYes, for that subsetBefore or during generation if the schema is unsupported
Post-generation validationOnly if parsing succeedsOnly if validation succeedsAfter generation

The prompt is an instruction. JSON mode and constrained generation are API controls. A post-generation validator runs in the application and can also follow either API mechanism. None removes the need to handle incomplete responses, model refusals, or transport errors.

Generation and validation

Schema-constrained generation can limit the tokens available at each step so the response stays within an allowed grammar. Post-generation validation checks a response that has already been generated. A provider may support only a subset of JSON Schema during generation even when a general validator accepts more constraints.

When a value arrives, the application should parse and validate it at its own boundary. On failure it can reject the value or retry with a precise error. Treating a partial object as complete hides the failure.

Structure and meaning

Consider {"file":"src/app.ts","line":12}. It may match the schema while line 12 does not exist, contains unrelated code, or lies outside the task’s scope. Check structure against the schema and meaning against the file and task. These are practical distinctions, not names for universal guarantees.

For an action, there are further decisions:

  1. Can the value be parsed?
  2. Does it satisfy the schema?
  3. Does it refer to a real, relevant thing?
  4. Is the requested use allowed and authorized?
  5. Did execution actually succeed?

An enum or a pattern can narrow values, but cannot establish user intent or grant authority. Those decisions require the application’s own data and policies.

Tool arguments

Tool calls use the same idea for a different destination. A model may produce structured arguments for read_file(path="src/app.ts"). The application validates the arguments and decides whether to execute the tool. Some APIs support strict schema adherence for tool arguments separately from structured final answers.

The schema makes the call easier to parse. The application must still check the path, scope, and authorization before execution.

References