Skip to main content
Zod is the most common way to define schemas in TypeScript. The Vercel AI SDK accepts Zod schemas directly; no conversion step is needed.

Install

Basic usage

Pass a Zod schema to generateObject. The AI SDK converts it to JSON Schema and sends it to dottxt:
The AI SDK adds additionalProperties: false automatically when converting Zod schemas.

Adding constraints and descriptions

Zod’s built-in methods translate to JSON Schema keywords. .describe() adds field-level descriptions that guide generation:

Streaming

Use streamObject to receive partial results as tokens stream in:

Notes

  • The AI SDK converts Zod schemas to JSON Schema before sending them to the API. To inspect the generated schema directly in Zod 4, use z.toJSONSchema():