Canonical: https://weaveos.com/glossary/structured-output

[Home](https://weaveos.com/)/[Glossary](https://weaveos.com/glossary)/[LLM fundamentals](https://weaveos.com/glossary/category/llm-fundamentals)/Structured output

[LLM fundamentals](https://weaveos.com/glossary/category/llm-fundamentals)

# Structured output

Also known as Structured generation, JSON mode

By WeavePublished September 10, 20262 min read

## 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.

On this page

1. [Definition](https://weaveos.com/glossary/structured-output#definition)
2. [Why a schema helps](https://weaveos.com/glossary/structured-output#article-why-a-schema-helps)
3. [Validation still matters](https://weaveos.com/glossary/structured-output#article-validation-still-matters)
4. [Design for change](https://weaveos.com/glossary/structured-output#article-design-for-change)
5. [A concrete example](https://weaveos.com/glossary/structured-output#article-a-concrete-example)
6. [How this relates to Weave](https://weaveos.com/glossary/structured-output#weave)
7. [Sources](https://weaveos.com/glossary/structured-output#sources)
8. [Related terms](https://weaveos.com/glossary/structured-output#related)

## 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](https://weaveos.com/products/token-intelligence)

## Sources and further reading

1. [Structured outputs, OpenAI API documentation](https://platform.openai.com/docs/guides/structured-outputs)

## Related terms

### [Tool calling](https://weaveos.com/glossary/tool-calling)

[How tool calling lets a language model request actions, what the application remains responsible for, and how to evaluate tool-using agents.](https://weaveos.com/glossary/tool-calling)

### [Evaluation metric](https://weaveos.com/glossary/evaluation-metric)

[What an AI evaluation metric measures, how to choose a metric for a task, and why one score rarely captures model quality.](https://weaveos.com/glossary/evaluation-metric)

### [Prompt injection](https://weaveos.com/glossary/prompt-injection)

[What prompt injection is, why it affects AI applications, and how teams can reduce its impact.](https://weaveos.com/glossary/prompt-injection)

### [LLM inference](https://weaveos.com/glossary/llm-inference)

[Understand LLM inference, how a trained model generates a response, and why input length and output length affect serving costs.](https://weaveos.com/glossary/llm-inference)
