Structured Output
Constraining LLM outputs to follow specific formats like JSON, XML, or custom schemas.
Overview
Structured output refers to techniques for constraining LLM generation to produce valid formatted data — typically JSON, XML, or outputs conforming to a specific schema. This is essential for integrating LLMs into software systems that require predictable, parseable outputs rather than free-form text.
Key Details
Approaches include grammar-constrained decoding (rejecting tokens that would violate the format), fine-tuning on structured output examples, and prompt-based approaches with strong formatting instructions. APIs from OpenAI, Anthropic, and others offer structured output modes that guarantee valid JSON. This capability is foundational for function calling, data extraction, form filling, and any application where LLM outputs feed into deterministic downstream systems.