AI-102 Implement generative AI solutions Practice Question
You are deploying a generative AI solution that must produce structured JSON order confirmations from free-text customer emails. Downstream systems reject any response that is not valid JSON matching a fixed schema. Which approach best guarantees schema-conformant output from an Azure OpenAI chat completion?
⚠ Common exam trap
The trap here is equating JSON mode with schema enforcement, when JSON mode only guarantees valid JSON syntax.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use a structured outputs configuration with a strict JSON schema that defines required fields and types.
Structured outputs constrain token generation to a supplied JSON schema, enforcing required fields and correct types so responses validate against the contract. JSON mode only guarantees syntactic validity, and few-shot examples or post-processing repairs do not provide a hard structural guarantee. For downstream systems that reject any schema deviation, constrained decoding is the most reliable approach.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Set the temperature to zero and include an example of the exact JSON output in the prompt.
Why it's wrong here
Few-shot examples and zero temperature improve consistency but do not enforce a schema. The model can still drift on edge-case emails, omit fields, or produce invalid types. Downstream validation would occasionally reject responses, requiring retries or manual fixes. While this approach is simple, it does not provide the hard guarantee that constrained decoding offers, so it is weaker for a strict contract.
- ✓
Use a structured outputs configuration with a strict JSON schema that defines required fields and types.
Why this is correct
Structured outputs constrain decoding so the generated tokens conform to a supplied JSON schema, including required properties and allowed types. This provides a strong guarantee that the response validates against the schema, which is exactly what downstream systems demand. Combined with a clear prompt, it removes the need for retry loops or brittle post-processing, making it the most reliable option for strict schema conformance.
- ✗
Set response_format to json_object and describe the desired schema in the system message.
Why it's wrong here
JSON mode ensures the output is syntactically valid JSON, but it does not enforce a specific schema. The model can omit required fields, add unexpected keys, or use wrong types while still producing parseable JSON. Downstream validation against a fixed schema would still fail intermittently. This option improves format reliability but does not guarantee structural conformance, so it is insufficient for the stated requirement.
- ✗
Request the output in JSON and run a regex-based validator that repairs any deviations before forwarding.
Why it's wrong here
Post-hoc validation and repair add complexity and can silently alter meaning when the model output is malformed in ways a regex cannot safely fix. It also increases latency and failure modes. The requirement is to guarantee conformance at generation time, not to patch outputs afterward. Constraining the decoder to the schema is more robust than attempting repairs on unpredictable text.
Go deeper
Related to this question
About these practice questions
Courseiva writes every AI-102 question from scratch — 761 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Microsoft exam blueprint
This AI-102 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AI-102 exam.