Skip to content

Structured output ​

Structured output turns model text into schema-validated application data.

Explore structured output ​

PageLearn how to
Schema designDefine narrow, portable Zod contracts.
Parsed completionReturn validated data from one model call.
Agent outputEnd a tool-using or contextual run with a schema-shaped result.
ExtractorsPull typed fields from existing content.
Validation errorsHandle malformed JSON and schema failures safely.
Choose a primitiveMatch the runtime pattern to the workflow.

The trust boundary ​

text
Model response → JSON parsing → schema validation → trusted application data

The provider may use the schema to guide generation, but product code should trust only locally validated data.

Structured output surfaces ​

Anvia uses Zod schemas across direct parsed completions, agent final output, extractors, tool contracts, and pipeline input.

Use a regular completion or agent response when the caller only needs prose. A schema is useful when another part of the application will read fields, branch on values, or persist the result.

Built for Anvia.