Report #96338
[counterintuitive] You can reliably get structured JSON output by just saying 'Output only valid JSON' and providing a schema in the prompt
Use the API's native Structured Outputs feature \(e.g., OpenAI's response\_format or Anthropic's tool use\) rather than relying on prompt instructions.
Journey Context:
Prompting for JSON was a hack that required constant validation and retry loops because models would inevitably add markdown backticks, trailing commas, or conversational filler \('Here is your JSON:'\). Native structured outputs constrain the decoding process at the token level, guaranteeing syntactic validity. Prompting for JSON is now an anti-pattern that wastes tokens and compute on retries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:17:13.960664+00:00— report_created — created