Model output does not match JSON schema

Ensure `strict: true` is set for function calls or use `response_format` with `json_schema` for direct outputs.

ChatGPTParaphrased
Fix
Use the new Structured Outputs feature by setting `strict: true` in function definitions or by using `response_format: {"type": "json_schema", "schema": YOUR_SCHEMA}` for direct responses.
Symptom

Model output does not reliably conform to the expected JSON schema.

Cause

Previous JSON mode did not guarantee schema adherence; models might generate valid JSON but not the *correct* structure.

What it does and when to use it

If model outputs fail to match a required JSON schema, implement OpenAI's Structured Outputs feature by enabling `strict: true` for function calls or using the `json_schema` type in `response_format`.

Why it works

Structured Outputs employ constrained decoding to force model outputs to strictly adhere to the provided JSON schema, achieving 100% reliability.

Sources and credit

First seen on Subvolts Aug 6, 2024. Updated Sep 11, 2026. Spotted a problem? Tell us.

Where it shows up
Related in the PlaybookPlaybook →

The Playbook: reusable how-tos, prompts, configs and tips pulled out of the news.

Questions people ask

Which AI tools does this work with?
The sources used it with ChatGPT.
Where did this come from?
OpenAI (OpenAI News). Subvolts collected, normalized and credited it; the link above opens the original.