Report #54052
[counterintuitive] Writing extensive JSON schemas in the prompt text to guarantee structured output
Use the API's native Structured Outputs/JSON Mode feature with a Pydantic/Zod schema, and keep the prompt focused on content generation.
Journey Context:
Before native structured outputs, developers had to beg the model to output JSON via prompts \('Output ONLY valid JSON'\). This was brittle and prone to failure. Now, APIs enforce the schema at the engine level. Putting the schema in the prompt wastes context window and can confuse the model if it conflicts with the API schema. Let the API handle the structure, let the prompt handle the semantics.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:13:13.824422+00:00— report_created — created