Agent runtime

Structured Outputs

Making a model return data in a declared schema — JSON that validates against a Pydantic or Zod model — so downstream code consumes typed fields instead of parsing prose.

Operating principle

Production AI is a system: context, tools, permissions, traces, evals, and feedback loops around the model.

What it is

Structured outputs constrain a model's response to a schema you declare, usually expressed as JSON Schema via a Pydantic model in Python or a Zod schema in TypeScript. Providers support it natively — OpenAI's structured outputs constrain decoding to the schema; Anthropic reaches the same guarantee through tool-based extraction — and frameworks add validation with automatic retry on failure.

Why it matters

Extraction, classification, and routing decisions only compose into pipelines when their outputs are machine-readable contracts. Schema-validated output is the difference between a demo that regex-parses model text and a workflow that runs unattended.

How we build it

Response schemas are Pydantic models on the Python side and Zod schemas at the TypeScript edges. Output validators reject a bad response and re-prompt the model with the specific validation error, and eval suites assert schema validity as its own check, separate from content quality.

Related resources