Structured Output and Generative UI
Make the model fill a form instead of writing a paragraph: JSON with a zod schema, partial objects while they stream, AI-filled forms, and screens built from a typed registry.
So far the model has written text for a person to read. Many features need something else: an order number the screen can look up, a status that picks a badge, a list of fields that fill a form. For that the model must answer in a shape your code can check, not in a paragraph.
This phase teaches the whole path. Why "please reply with JSON" is not enough, how to describe the shape with zod, how the AI SDK's Output.object asks for it and what it throws when the answer is wrong, how to show a half-finished object while it streams, how to let the model fill a form without trusting it, and how to let the model choose which component to show from a list you control.
Every example runs the real AI SDK 7 and zod in the page, against a scripted stand-in model that you can make misbehave on purpose. The phase ends with Mitra showing cards, not paragraphs, for order status and products.
Practise this phase
Hands-on exercises: write the code, see your page live, and press Check to have it tested automatically.