Structured Output Error

the codes

import { GoogleGenAI } from “@google/genai”;

import { z } from “zod”;

import { zodToJsonSchema } from “zod-to-json-schema”;

const ingredientSchema = z.object({

name: z.string().describe(“Name of the ingredient.”),

quantity: z.string().describe(“Quantity of the ingredient, including units.”),

});

const recipeSchema = z.object({

recipe_name: z.string().describe(“The name of the recipe.”),

prep_time_minutes: z.number().optional().describe(“Optional time in minutes to prepare the recipe.”),

ingredients: z.array(ingredientSchema),

instructions: z.array(z.string()),

});

const ai = new GoogleGenAI({

apiKey: process.env.KEY,

});

const prompt = `

Please extract the recipe from the following text.

The user wants to make delicious chocolate chip cookies.

They need 2 and 1/4 cups of all-purpose flour, 1 teaspoon of baking soda,

1 teaspoon of salt, 1 cup of unsalted butter (softened), 3/4 cup of granulated sugar,

3/4 cup of packed brown sugar, 1 teaspoon of vanilla extract, and 2 large eggs.

For the best part, they’ll need 2 cups of semisweet chocolate chips.

First, preheat the oven to 375°F (190°C). Then, in a small bowl, whisk together the flour,

baking soda, and salt. In a large bowl, cream together the butter, granulated sugar, and brown sugar

until light and fluffy. Beat in the vanilla and eggs, one at a time. Gradually beat in the dry

ingredients until just combined. Finally, stir in the chocolate chips. Drop by rounded tablespoons

onto ungreased baking sheets and bake for 9 to 11 minutes.

`;

const response = await ai.models.generateContent({

model: “gemini-3.5-flash”,

contents: prompt,

config: {

responseFormat: { text: { mimeType: "application/json", schema: zodToJsonSchema(recipeSchema) } },

},

});

const recipe = recipeSchema.parse(JSON.parse(response.text));

console.log(recipe);

the image is the output on my terminal