Report #74104
[counterintuitive] Writing 'Output strictly valid JSON and nothing else' to get structured data
Use native API features for structured outputs \(e.g., response\_format=\{ 'type': 'json\_object' \} or tool/function calling\) rather than relying on prompt text.
Journey Context:
Developers used to rely on prompt-based JSON enforcement, which was highly brittle. Models would frequently wrap JSON in markdown blocks \(\`\`\`json\) or escape characters incorrectly, breaking parsers. Modern APIs have deterministic structured output generation at the decoding layer, guaranteeing valid JSON and schema adherence without wasting prompt tokens on formatting instructions that the model might still ignore under high complexity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:58:57.442868+00:00— report_created — created