Structured Output
Make a model return data a program can trust: JSON mode, schemas, validation, repair loops, honest unknowns, and one typed-call function in three languages.
A chat window can show any text. A program cannot. It needs fields: a label from a fixed list, a number in a range, a date, a yes or a no. This phase is about getting those from a model reliably, which is harder than it sounds. A model writes text one piece at a time. Nothing forces that text to be valid JSON, let alone the JSON your code expects.
You will start with the failures: replies wrapped in chatter, cut off in the middle, or using the wrong field names. Then you build each defence by hand, in order. First a tolerant extractor, then a validator that writes errors a model can act on, then a repair loop that sends those errors back, and last an honest way to say "I don't know". Only after that do you meet the library versions (Pydantic, Jackson with Bean Validation, Zod) and the provider features (JSON mode and schema-constrained output).
Every example runs on this page in Python, Java and JavaScript with the same output, using scripted fake models. Two real-model labs let you see JSON mode and a null-instead-of-invention extraction on a free hosted model. The phase ends with the playbook: one typed-call function you can copy.
Practise this phase
Hands-on exercises: write the code, run it, and press Check to have it tested automatically.