Output schema

Hello everyone. I'd like to confirm my understanding of how output schemas work.

I have the following code in a flow, with MyOutputModel being a Zod schema:

const { output } = await ai.generate({
model: model,
prompt: renderedPrompt,
output: { schema: MyOutputSchema },
});

I have considered to be explicit in the prompt with an example output (json ofc). My understanding is that this actively guides the model to create the correct output in JSON format. Is the schema sufficient or should I add the example directly in the prompt? Tests seem to indicate that the schema is sufficient...

Thanks in advance!
Was this page helpful?