AI-103 Practice Question 14: Structured Outputs JSON Schema
Microsoft Azure AI Apps and Agents Developer Associate (AI-103) · Test 2 · question 4 of 10
A claims service prompts a chat model to return a claimant name, a policy number, and an array of line items, then calls json.loads on the content and indexes the fields directly. Roughly two percent of responses parse as valid JSON but omit one of the required properties or invent an extra one, and the downstream code raises a KeyError. The team wants the model itself constrained to the shape, not more validation code around it.
What should they configure on the request?
Show answer and explanation
Answer:
Structured outputs make the model follow a JSON Schema you supply as part of the inference call. For Chat Completions you define it in response_format as a json_schema with strict: true; for the Responses API the equivalent lives under text.format. The documentation draws the contrast directly: this approach replaces the older JSON mode, which "guaranteed valid JSON but couldn't ensure strict adherence to the supplied schema". Note the schema rules: every property must be listed in required, and each object must set additionalProperties: false.
- A is wrong because json_object *is* JSON mode, and JSON mode is precisely the behaviour the team already has: syntactically valid JSON with no guarantee about which keys appear. - B is wrong because prompt instructions and a low temperature are best-effort. Temperature 0 makes output more repeatable, not schema-conformant, and the residual failures are what the team is trying to eliminate. - C is wrong because it adds the validation-and-retry code the team explicitly wanted to avoid, and it pays for extra model calls to recover from a failure the service can prevent.
Reference: How to use structured outputs with Azure OpenAI in Microsoft Foundry Models