AI and LLMs · Middle · Question 18 of 75
Why validate structured output with a schema library like Zod even when the model was asked for JSON?
- 1Zod makes the model generate answers faster
- 2Output can still be malformed or have wrong types
- 3JSON from models can't be parsed without Zod
Show the answer
Correct answer: Output can still be malformed or have wrong types
Explanation
Validate, and on failure retry with the error message or fall back. Never pass unvalidated model output into code paths that trust it.