Zod’s built-in methods translate to JSON Schema keywords. .describe() adds field-level descriptions that guide generation:
const SupportTicket = z.object({ category: z.enum(["billing", "account", "bug", "feature"]) .describe("The area this ticket relates to."), priority: z.enum(["low", "medium", "high"]) .describe("How urgently this ticket needs attention."), summary: z.string().min(10).max(500) .describe("A brief description of the issue."), confidence: z.number().min(0).max(1) .describe("How confident the model is in the classification."),}).describe("A customer support ticket.");const { object } = await generateObject({ model: dottxt.chat("openai/gpt-oss-20b"), schema: SupportTicket, prompt: "Classify: I can't access my billing portal and it's blocking a renewal.",});
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():