Definition
What is LLM structured output?
Last updated
Definition
Structured output is the LLM capability of returning responses that conform to a predefined schema (typically JSON) — guaranteed by the model's API, not just requested in the prompt.
Most modern LLM APIs support a "JSON mode" or "structured output" feature that constrains the model's output to match a JSON schema you provide. This eliminates the parsing-failure class of bugs that plague prompt-only approaches. OpenAI's structured outputs, Anthropic's tool use, and Gemini's response schema all do this. For production agents, structured output is non-optional — without it you're writing brittle string parsers.
Why “JSON mode” beats “asking for JSON”
Pre-structured-output, you’d ask respond with JSON like {x: ..., y: ...} and parse the response. Failure modes: trailing commas, wrong keys, prose before/after the JSON, hallucinated fields. Structured output eliminates these by constraining the model’s sampling to valid schema-conforming tokens.
Where it fits in agents
Anywhere the agent’s next step depends on parsing structured fields out of the LLM output: tool calls, classification labels, decisions to escalate, etc.