Report #100406
[counterintuitive] To get structured output, you must beg the model in the prompt with 'respond ONLY in valid JSON' and include examples.
Use native structured outputs / constrained decoding. Pass a JSON Schema via response\_format/text.format \(OpenAI\) or output\_format \(Anthropic\). Do not rely on prompt wording to enforce syntax; the API guarantees schema compliance at the token level.
Journey Context:
OpenAI's Structured Outputs \(json\_schema\) and Anthropic's structured outputs compile the schema into a grammar and restrict token generation during inference. OpenAI's docs explicitly state 'Simpler prompting: No need for strongly worded prompts to achieve consistent formatting.' JSON mode still required asking for JSON; Structured Outputs does not. Tool definitions with strict: true are another native path. Writing 'respond in JSON' with regex parsers and retry loops is a 2023 workaround that is now obsolete for supported models.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-01T05:10:25.030782+00:00— report_created — created