Mรณdulo 15 ยท LLM Foundations โ Lecciรณn 3 de 4 ยท ~11 min
Structured output
The killer idea: make the type the contract
Your system prompt asks for structured output. But asking isn't enforcing โ the model can still hand back prose on a bad day, and now your code has to defend against it. This lesson removes the hope.
Pydantic AI is the library the real backend uses. Its central object is an Agent, and its killer feature is one keyword: output_type. You give it a Pydantic model, and the agent guarantees the model's reply matches that schema โ validating the output and retrying the model if it doesn't โ before your code ever sees it.