OpenAI API · api · fg-0143

Strict structured output rejects the schema: 'required' must include every key in properties

If you see Invalid schema for response_format: In context=(), 'required' is required to be supplied and to be an array including every key in properties, the cause and the fix for OpenAI API are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Invalid schema for response_format: In context=(), 'required' is required to be supplied and to be an array including every key in properties.400 invalid_json_schema for a Pydantic model with an optional or dict fieldZod discriminated union at the root is rejected
Cause
With strict set to true every property must be listed in required, every object needs additionalProperties false, and the root must be a plain object, not anyOf. Optional fields and open maps break those rules.
Fix
Make optional fields required but nullable, replace free form dicts with arrays of key and value objects, and wrap unions inside a root object.
Apply
{"type": "object", "additionalProperties": false, "required": ["name", "nickname"], "properties": {"name": {"type": "string"}, "nickname": {"type": ["string", "null"]}}}
Affected
OpenAI Structured Outputs with strict true, Responses and Chat Completions, checked October 2026
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun