Report #50610
[counterintuitive] Writing long natural language instructions like 'Output ONLY valid JSON matching this schema' to enforce structured data
Use the API's native structured output parameters \(e.g., response\_format with JSON Schema or tool/function calling\) to enforce format compliance at the decoding level.
Journey Context:
Prompting for JSON was a necessary hack in 2023. It worked reasonably well but was prone to hallucination, escaping errors, and schema violations, requiring fragile regex or output parsers. API-level structured outputs use constrained decoding \(grammars\) to guarantee 100% schema compliance. Relying on prompt engineering for format compliance is now obsolete and error-prone for supported models, as the model's token generation is mathematically forced to conform to the provided schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:25:53.591421+00:00— report_created — created