Structured output
Also known as Structured generation, JSON mode
Definition
Structured output is a model response constrained to a defined shape such as JSON with named fields and types. It gives application code a predictable contract while leaving the model responsible for generating the field values.
Why a schema helps
Free-form text is difficult to validate reliably. A schema can require fields such as priority, reason, and next_action, with explicit types and allowed values. The application can reject or retry a response that does not satisfy the contract before it reaches a database or tool.
Validation still matters
A valid JSON object can contain a wrong answer. Check ranges, permissions, references, and business rules in ordinary application code. Keep the model's uncertainty visible when a human needs to review the result.
Design for change
Version schemas and measure failures by model, prompt, and route. Weave's token and trace views help teams see whether a schema change improved useful completion or only increased retries and token spend.
A concrete example
Imagine a support assistant that classifies a request before sending it to a queue. A structured response might include a category, urgency level, short rationale, and a boolean that says whether a human should review it. The service can validate the allowed categories and reject an impossible urgency value before creating a ticket. Logging the validation result also gives the team a useful failure signal. If the model returns a plausible category but the wrong urgency, the response passed the shape check and still needs a quality evaluation. That distinction keeps reliability metrics honest and helps engineers improve the prompt, schema, or routing decision that actually caused the error.
How this relates to Weave
Weave can capture the schema, model route, validation result, and downstream outcome for structured responses. That helps teams distinguish a malformed response from a correct schema containing an incorrect value.
Explore Token intelligence