An API must always return JSON that matches a schema. What is the strongest control?
Why D is the answer
Schema-constrained structured output
Constraints enforce the format, and instructions only request it.
In detail
- Constraints enforce the format.
- Instructions only request it.
- Instructions only request the format.
Use case
An illustrative scenario, not a real incident.
An API must always return valid JSON, so output is constrained to a schema.
See it in different ways
flowchart TD
A{"What goes wrong?"} -->|"Wrong format"| B["Few-shot and structured output"]
A -->|"Logic errors"| C["Chain of thought"]
A -->|"Made-up facts"| D["Retrieval and grounding"]mindmap
root((Prompting))
Format drift
Few-shot examples
Structured output
Reasoning errors
Chain of thought
Simple tasks
Zero-shot
Domain words
Context in the promptflowchart TD
Q{"How strict is the need?"}
Q -->|"Must always match"| A0["Schema-constrained output"]
Q -->|"Usually fine"| A1["Prompt instructions"]Key point: Constraints enforce the format.
Why the other options are wrong
- A. A polite request in the system prompt to follow JSON
- A polite request is not enforcement.
- B. A higher temperature, which gives more varied answers
- More variety makes it worse.
- C. A note to the user explaining how to fix bad JSON
- Users should not fix it.

