Generate Object

Structured Data Zod Schema Type-safe

Generate structured JSON objects that conform to a Zod schema. Perfect for creating typed data like notifications, cards, or extracting structured information from AI responses.

Demo

Step 1: Define Your Schema

Start by defining a Zod schema. The .describe() method helps the AI understand what each field should contain.

schema.ts

Step 2: Create API Endpoint

The api uses generateText with Output.object() to ensure the response adheres to our Zod schema. This allows us to receive fully typed data on the client.

+server.ts

Step 3: Create Notification Component

Let's build a simple Svelte component to display the generated notifications. This component will receive the structured data from our API.

+page.svelte