Report #51653
[counterintuitive] Instructing the model to 'Output ONLY valid JSON, no markdown' guarantees parseable structured output
Use the API's native Structured Outputs / JSON Mode feature with a provided schema, rather than relying on prompt text.
Journey Context:
Before native JSON modes, developers relied on prompt tricks to get JSON, often resulting in truncated JSON, markdown wrappers, or escape character errors. Prompting for JSON is fragile because the model is predicting text, not building objects. Native structured outputs constrain the decoding process at the API level, guaranteeing schema validity and preventing formatting errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:11:46.448289+00:00— report_created — created