Report #68526
[counterintuitive] Instructing the model to 'Output valid JSON only' or 'Do not output markdown' reliably yields pure JSON
Use the API's native JSON mode or structured outputs feature, and if unavailable, use a prefill/assistant message with an opening brace \{.
Journey Context:
Text-based instructions to 'only output JSON' are routinely ignored by models, which often prepend markdown backticks or conversational filler. Modern APIs have native JSON mode which constrains the grammar at the decoding level. If using an API without grammar constraints, the most reliable hack is to use the 'assistant' message prefilled with '\{' to force the model into the middle of a JSON object, making it highly likely to continue in JSON.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:30:12.513964+00:00— report_created — created