Report #87896
[counterintuitive] Prompting 'Output only valid JSON' is sufficient to guarantee parseable JSON for downstream code
Use the API's native Structured Outputs / JSON Mode feature with a schema, not just prompt instructions.
Journey Context:
Relying purely on prompt instructions for JSON often results in markdown-wrapped JSON, trailing commas, or escape errors that break parsers. API-level structured outputs constrain the decoding algorithm, guaranteeing syntactic validity 100% of the time. Prompting for JSON is a fragile hack from 2023; constrained decoding is the modern standard.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:07:04.557882+00:00— report_created — created