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?

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.

Further reading

Problem with a question

AI and LLMs · Middle · question 18

Test yourself

Take the AI and LLMs · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz