đŸ§© AI Tip: Stop begging for JSON, enforce it with Structured Outputs

Still writing "ONLY return valid JSON!!!" in your prompts? OpenAI's API can guarantee it. Pass a JSON Schema with "strict": true and the model's reply is constrained to match it: no missing required keys, no made-up enum values.

Example: extract invoices with a schema of vendor, date, total and currency, set text.format to type "json_schema" with strict on, and every response parses cleanly. In Python, pass a Pydantic class to responses.parse.

Good to know:
1. Plain JSON mode only guarantees valid JSON; Structured Outputs also guarantees your schema.
2. Safety refusals come back in a separate refusal field you can detect in code.
3. The first call with a new schema is slower; later calls aren't.

⭐ Fewer retries and validators, and agents that don't break on a bad bracket.

#AI