---
title: "Structured outputs"
type: "glossary term"
url: "https://aifordevs.org/glossary#structured-outputs"
markdown: "https://aifordevs.org/glossary/structured-outputs.md"
publisher: "AI for Devs"
license: "https://aifordevs.org/reuse"
attribution: "Credit AI for Devs and link to https://aifordevs.org/glossary#structured-outputs"
---

# Structured outputs

Structured outputs is an API feature that constrains a model's output to match a JSON Schema you supply, so successful responses parse against your schema. It is usually implemented with constrained decoding, which masks tokens that would break the schema.

Handle the exceptions: a refusal can return text outside the schema, and hitting a token limit can cut the JSON short. Check the refusal field or stop reason before parsing. The first request with a new schema adds latency while the API processes it.

## Example

On the Claude API, set output_config.format to a json_schema and read stop_reason before calling JSON.parse. A stop_reason of max_tokens means the JSON may be truncated.

## Source

[Anthropic docs: Structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

## Related terms

- [Tool calling](https://aifordevs.org/glossary#tool-calling)
- [Constrained decoding](https://aifordevs.org/glossary#constrained-decoding)

## Cite this term

AI for Devs. "Structured outputs." https://aifordevs.org/glossary#structured-outputs

- Page: https://aifordevs.org/glossary#structured-outputs
- Markdown: https://aifordevs.org/glossary/structured-outputs.md
- Reuse: Quote or summarize with a link to this page. Terms: https://aifordevs.org/reuse
- Publisher: AI for Devs
