Report #28778
[counterintuitive] Prompting 'Output ONLY valid JSON, no other text' to get structured data
Use API-level structured outputs \(JSON mode / Structured Outputs\) rather than prompt-based format forcing.
Journey Context:
In 2023, developers begged models in text to output JSON, often resulting in markdown-wrapped JSON or trailing commas that broke parsers. Prompting for format is fragile and fights the model's natural token distribution. API-level structured outputs constrain the decoding process, guaranteeing syntactic validity and schema adherence 100% of the time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:41:49.701115+00:00— report_created — created