Report #76692
[counterintuitive] Writing 'Output only valid JSON, no markdown fences' in the prompt to get structured data
Use the API's native JSON mode or Structured Outputs parameter to enforce grammar at the token level.
Journey Context:
Developers used to beg models not to wrap JSON in markdown. It was fragile and required regex stripping. Modern APIs support constrained decoding at the token level. If you ask for JSON in text, you are fighting the model's natural distribution, which often includes markdown formatting. Using the API parameter forces the grammar engine to only allow valid JSON tokens, guaranteeing 100% parseability without prompt hacks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:19:02.676392+00:00— report_created — created