PhyseaWiki How AI actually works Papers physea.ai →

Structured output

How do you make a model match an exact JSON shape?

JSON mode guarantees parseable JSON but not its shape. Passing a JSON Schema with strict mode pins the exact fields, types, and allowed values, so the output matches what your code expects.

Last updated 2026-06-15 · Physea Labs

There are two levels of help, and they are easy to confuse.

JSON mode asks the model to return only valid JSON. The text will parse, but nothing checks that it has the fields you wanted. OpenAI calls this json_object and notes that JSON mode “only ensures valid JSON output,” in contrast to the stronger option below.[1]

Schema-enforced output goes further. You hand the model a JSON Schema, a small specification listing the field names, their types, and any fixed set of allowed values. You then turn on strict mode. OpenAI’s version is response_format: { "type": "json_schema", "json_schema": { "strict": true, ... } }, and the guide recommends “always using Structured Outputs instead of JSON mode when possible.”[1] Anthropic offers the same idea: structured outputs “constrain Claude’s responses to follow a specific schema,” giving output that is “Always valid,” “Type safe,” and “Reliable.”[2]

There is a second place this shows up: tool calls. When a model calls a function, its arguments are themselves structured data, so the same schema enforcement applies there. OpenAI separates the two uses, noting that response_format is “more suitable when you want to indicate a structured schema for use when the model responds to the user, rather than when the model calls a tool.”[1] Anthropic exposes this as strict: true on a tool to “guarantee schema validation on tool names and inputs.”[2] Before native schema support existed, the common trick was the reverse: define a tool whose input matches your desired data, then force the model to call it.

Heads up Support varies by model. OpenRouter notes structured outputs “are supported by select models” and that a request can “fail with an error indicating lack of support,” so check before you depend on it.[3]

Structured-output features by provider

References

  1. Structured model outputs — OpenAI
  2. Structured outputs — Anthropic
  3. Structured Outputs — OpenRouter