Report #41081
[counterintuitive] Prompting 'Output ONLY valid JSON, no markdown, no other text' to get structured data
Use the API's native structured output/JSON mode parameters \(e.g., response\_format: \{ type: 'json\_object' \} or response\_format: \{ type: 'json\_schema' \}\) and include a JSON schema in the system prompt.
Journey Context:
Text-based JSON prompting was notoriously brittle; models would frequently append markdown wrappers or trail off with comments. Native JSON mode constrains the decoding algorithm to only output valid JSON tokens. Schema enforcement guarantees the keys exist, eliminating the need for regex-based post-processing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T23:25:23.233627+00:00— report_created — created