Skip to main content
Pass an output_schema to constrain the agent’s final answer to a typed shape. The SDK validates the model’s output against the schema and returns a typed object.

Pydantic / Zod

Other schema sources

Both SDKs accept raw JSON Schema. Python additionally accepts dataclasses and TypedDict. TypeScript accepts any Standard Schema implementation (Valibot, ArkType, etc.).
Python

Without a schema

Omit output_schema and the agent returns a string in result.output.