Report #62059
[counterintuitive] Prompting 'Return ONLY valid JSON, no markdown' to get structured data from an LLM
Use native Structured Outputs / JSON Mode with a provided JSON Schema or Pydantic model definition.
Journey Context:
Prompting for JSON was a hack before native support. It frequently failed \(hallucinated markdown fences, escaped quotes badly, omitted closing brackets\) because LLMs predict text, not objects. Native structured outputs constrain the decoding to guarantee syntactic validity and schema adherence, eliminating the need for regex-based extraction or retry loops for malformed JSON.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:39:12.621908+00:00— report_created — created