wiki / concepts / structured-outputs

Structured Outputs

high confidence updated 2026-08-30 llm-fundamentals · context-engineering · patterns

Structured Outputs

Often the thing you want back from an LLM is not text but an object: extracting multiple properties from unstructured input (PDFs, comments, documents) is one of the most powerful and business-relevant LLM use cases, alongside classification into enums/categories.

{
  "name": "verdict",
  "strict": true,
  "schema": {
    "type": "object",
    "properties": { "pass": {"type": "boolean"}, "reason": {"type": "string"} },
    "required": ["pass", "reason"],
    "additionalProperties": false
  }
}

Variants

  • Object generation: pass a JSON schema, receive a typed object (data extraction from PDFs and other unstructured sources).
  • Enum generation: constrain output to a fixed set of enumerated values (classification, sentiment, routing).
  • Array generation: schema with multiple items for batch extraction.
  • Streaming objects: instead of waiting for the whole object, stream it field-by-field as generation proceeds.
  • Tool-based structuring: reuse tool calling loop infrastructure — declare a tool whose arguments are your schema and force the model to call it — to get the same shape guarantees without a dedicated structured-output API.

Why It Matters

Structured outputs are the bridge between probabilistic text generation and deterministic application code: they make LLM output consumable by databases, validators, and pipelines. The pattern pairs naturally with evals skills — schema conformance is cheap to verify automatically, a rare machine-checkable oracle.

Failure Modes

SymptomRoot causeFix
Schema violated at runtimeModel improvises fieldsStrict schema mode + validation retry on parse failure
Over-constrained schema chokes outputToo many required fieldsRequired only what downstream code reads; everything else optional
Silent parse fallbackJSON extracted with regexFail loudly on malformed output; route to retry, never to guess

Rule of Thumb

Schema conformance is the cheapest deterministic oracle available - prefer it over any judge when the property is checkable.

llm message protocol, tool calling loop, model provider abstraction, evals skills, generator evaluator loop.

Evidence — verified primary sources
raw/aihero-video/wiUXxKeFSz8JTwQvmZ7ut029nJ23PevCst8ylkrCHtTU.md internal workspace doc
raw/aihero-video/NR9LollfJgzuMq02zxZn6nnhQjMVcTQ2vkhvc8Xz2025U.md internal workspace doc
raw/aihero-video/uygTjLE2W4XQs5Qla01MRI1arhqTtui2gOCQqFMlIlEs.md internal workspace doc
raw/aihero-video/ZxadOHgUN02s99h3Jhp01TwEcbgKVmWUkA9qnwOM3eMI4.md internal workspace doc
raw/aihero-video/PG15cq802CeSluIc6YM7CV927SX01MbOUpQ01FBVXN8WlI.md internal workspace doc