OpenAI "Invalid schema for response_format": 'additionalProperties' is required to be supplied and to be false
This is an HTTP 400 from the OpenAI API, returned when a JSON Schema sent with Structured Outputs — a json_schema response format or a function tool with strict: true — breaks one of two documented rules: every object must set additionalProperties: false, and every key in properties must be listed in required. Its sibling reads 'required' is required to be supplied and to be an array including every key in properties. The schema is at fault, so retrying the same request will not help.
The 30-second answer
- Add
"additionalProperties": falseto every object in the schema — the root, nested objects, arrayitemsobjects and everything under$defs. - List every property in
required. For an optional field, keep it inrequiredand make its type a union withnull, e.g.["string", "null"]. - Using Pydantic? Pass the model class to the SDK (
parse()orpydantic_function_tool) instead of sendingModel.model_json_schema()yourself — the difference is shown below. - Free-form maps do not fit.
Dict[str, ...]fields andextra="allow"models still produce a non-compliant schema, even through the SDK helper. - The rules are documented by OpenAI; the response_format error wording is user-reported.
The exact error
The wording most people search for, as posted by a user in openai-python issue #2740:
Error code: 400 - {'error': {'message': "Invalid schema for response_format 'MyClass': In context=(), 'additionalProperties' is required to be supplied and to be false.", 'type': 'invalid_request_error', 'param': 'response_format', 'code': None}}
The sibling, as posted in openai-python issue #2533 (a Responses API call, hence the different param):
Error code: 400 - {'error': {'message': "Invalid schema for response_format 'ReviewSentiment': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Extra required key 'aspect_sentiment' supplied.", 'type': 'invalid_request_error', 'param': 'text.format.schema', 'code': 'invalid_json_schema'}}
Where this wording comes from: both response_format strings above are user-reported — copied from issues filed by users on OpenAI's GitHub repositories, not from an OpenAI documentation page. We did not find either string on an official docs page on 9 November 2026. The function-tool form of the first message is in an official OpenAI source: a recorded API response checked into OpenAI's openai-dotnet test recordings, fetched today (request summarised on the first line, status and response body as recorded):
POST https://api.openai.com/v1/chat/completions (model "gpt-4o-2024-08-06", one tool with "strict": true and no "parameters")
StatusCode: 400
{
"error": {
"message": "Invalid schema for function 'get_favorite_color_for_day_of_week': In context=(), 'additionalProperties' is required to be supplied and to be false.",
"type": "invalid_request_error",
"param": "tools[0].function.parameters",
"code": "invalid_function_parameters"
}
}
User reports show two suffixes on the 'required' message: Extra required key '<name>' supplied. (issue #2533 and openai-java issue #485) and Missing '<name>' (codex issue #547). Both are user-reported only.
Verified against OpenAI's docs and the Python SDK — 9 November 2026
Confirmed on official pages fetched today. OpenAI's Structured Outputs guide (the URL now redirects to developers.openai.com/api/docs/guides/structured-outputs) has a "Supported schemas" section with these headings and sentences:
- "
additionalProperties: falsemust always be set in objects" — "Structured Outputs only supports generating specified keys / values, so we require developers to setadditionalProperties: falseto opt into Structured Outputs." - "All fields must be
required" — "To use Structured Outputs, all fields or function parameters must be specified asrequired." - "it is possible to emulate an optional parameter by using a union type with
null." - "If you turn on Structured Outputs by supplying
strict: trueand call the API with an unsupported JSON Schema, you will receive an error."
The function calling guide repeats both requirements under "Strict mode" and adds: "If you send strict: true and your schema does not meet the requirements above, the request will be rejected with details about the missing constraints." Neither guide prints the message text.
Run locally today (client-side only, no API call). Environment: openai==3.48.0, pydantic==2.14.3, Python 3.11.9, macOS. A script built a Person model (with an optional nickname and a nested Address with an optional zip) and printed, for every object in each generated schema, whether additionalProperties and required were set. Output, pasted unedited:
openai 3.48.0 | pydantic 2.14.3 | python 3.11.9 | Darwin
[1 Person.model_json_schema() (plain pydantic)]
(root) additionalProperties=MISSING properties=['name', 'nickname', 'address'] required=['name', 'address']
/$defs/Address additionalProperties=MISSING properties=['city', 'zip'] required=['city']
[2 to_strict_json_schema(Person) (SDK helper)]
(root) additionalProperties=False properties=['name', 'nickname', 'address'] required=['name', 'nickname', 'address']
/$defs/Address additionalProperties=False properties=['city', 'zip'] required=['city', 'zip']
nickname -> {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Nickname"}
[3 chat response_format built by the SDK from Person]
type = json_schema | name = Person | strict = True | schema identical to (2): True
[4 Responses text.format built by the SDK from Person]
type = json_schema | name = Person | strict = True | schema identical to (2): True
[5 openai.pydantic_function_tool(Person)]
strict = True | parameters identical to (2): True
[6 to_strict_json_schema(Loose) model_config extra='allow']
(root) additionalProperties=True properties=['name'] required=['name']
[7 to_strict_json_schema(Bag) field counts: Dict[str, int]]
(root) additionalProperties=False properties=['counts'] required=['counts']
/properties/counts additionalProperties={'type': 'integer'} properties=[] required=MISSING
counts -> {"additionalProperties": {"type": "integer"}, "title": "Counts", "type": "object"}
Plain model_json_schema() (block 1) breaks both documented rules. The SDK's own conversion (blocks 2–5) fixes both on the root and under $defs, rewrites the optional field as a union with null, and sets strict to true. Blocks 6 and 7 are the exceptions: extra="allow" leaves additionalProperties=True, and a Dict[str, int] field becomes an object whose additionalProperties is a sub-schema with no properties.
Not verified: no request was sent to OpenAI, so we did not reproduce the 400 ourselves and cannot confirm the message text, param or code values the live API returns today. The openai-dotnet recording has its date sanitized, so its age is unknown. We found no official explanation of the context=() notation; in every example above it accompanies a problem at the root of the schema.
Cause 1: an object without additionalProperties: false
The usual source is a hand-written schema, or one exported from a library (block 1 above) and sent as-is. The rule applies to every object, not only the root. A compliant version of the test schema, with the optional fields written the documented way:
{
"type": "object",
"properties": {
"name": { "type": "string" },
"nickname": { "type": ["string", "null"] },
"address": {
"type": "object",
"properties": {
"city": { "type": "string" },
"zip": { "type": ["string", "null"] }
},
"required": ["city", "zip"],
"additionalProperties": false
}
},
"required": ["name", "nickname", "address"],
"additionalProperties": false
}
The guide's markdown version shows the Responses API text.format form; the HTML page also carries Chat Completions examples using response_format. As the page shows them:
# Chat Completions
response_format: { type: "json_schema", json_schema: {"strict": true, "schema": ...} }
# Responses API
text: { format: { type: "json_schema", "strict": true, "schema": ... } }
With Pydantic, the lower-effort fix is to stop generating the schema yourself. These calls exist in openai 3.48.0 and produced the compliant schemas in blocks 3–5 (signatures checked locally; not sent to the API):
from openai import OpenAI, pydantic_function_tool
from pydantic import BaseModel
from typing import Optional
class Person(BaseModel):
name: str
nickname: Optional[str] = None
client = OpenAI()
# Let the SDK build the strict schema - pass the class, not Person.model_json_schema()
client.chat.completions.parse(model=MODEL, messages=msgs, response_format=Person)
client.responses.parse(model=MODEL, input=msgs, text_format=Person)
# Strict function tool from the same class
tools = [pydantic_function_tool(Person, name="save_person")]
Cause 2: a property missing from required
Leaving a key out of required to make it optional is not allowed here: the guide says all fields must be required and the model "will return a value for each parameter". Add every key in properties to required on that object, and express "optional" as a union with null — "type": ["string", "null"], or the anyOf form the SDK emitted for nickname in block 2.
Cause 3: free-form maps and extra="allow"
A dictionary with arbitrary keys cannot satisfy "additionalProperties must be false". Blocks 6 and 7 show the Python helper passing such schemas through unchanged, and the user reports match: issue #2533 is a Dict[str, str] field, openai-java #485 is a Map<String, Integer>, and issue #2740 is extra="allow". Remove extra="allow", and replace open maps with something the supported subset can describe — for example an array of objects with fixed key and value properties. That replacement is our suggestion; OpenAI's guide does not prescribe one.
Cause 4: a strict function tool with missing or loose parameters
The same two rules apply to parameters when a tool sets strict: true. The openai-dotnet recording above is the minimal case: a strict tool with no parameters at all was rejected with code: invalid_function_parameters. The function calling guide's own strict example:
{
"type": "function",
"name": "get_weather",
"description": "Retrieves current weather for the given location.",
"strict": true,
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and country e.g. Bogotá, Colombia"
},
"units": {
"type": ["string", "null"],
"enum": ["celsius", "fahrenheit"],
"description": "Units the temperature will be returned in."
}
},
"required": ["location", "units"],
"additionalProperties": false
}
}
If the tool genuinely needs a loose schema, the guide's documented opt-out is strict: false, which gives "non-strict, best-effort function calling". It also says that when strict is omitted, Responses requests "attempt to normalize your schema into strict mode when possible" and fall back to non-strict otherwise, while "Chat Completions requests remain non-strict by default".
Cause 5: other limits of the supported schema subset
If both rules are satisfied and a strict schema is still rejected, check the remaining limits listed in the guide today. We have no verified error wording for any of these:
- The root must be an object and must not be an
anyOf. - Not supported:
allOf,not,dependentRequired,dependentSchemas,if,then,else. - Up to 5000 object properties in total and up to 10 levels of nesting.
- Property names, definition names, enum values and const values together: at most 120,000 characters.
- Up to 1000 enum values across all enum properties.
- Each schema nested inside an
anyOfmust itself follow the subset, includingadditionalProperties: false.$defsand recursive schemas are supported.
FAQ
Is this exact error message in OpenAI's documentation? Not on the pages checked on 9 November 2026. The Structured Outputs and function calling guides state the rules (additionalProperties: false on every object, every field required) and say a non-compliant strict schema is rejected, but they do not print the message. The 'Invalid schema for function' wording appears verbatim in a recorded API response in OpenAI's openai-dotnet repository; the 'Invalid schema for response_format' wording is taken from user reports in the issue trackers of OpenAI's SDK repositories.
How do I keep a field optional if every property must be in required? OpenAI's Structured Outputs guide says to emulate an optional field with a union with null: keep the key in required and give it a type such as ["string", "null"]. The model then always returns the key, with null when there is no value.
I use Pydantic and never wrote a schema. Why do I get this error? In a local check with openai 3.48.0 and pydantic 2.14.3, plain Model.model_json_schema() left additionalProperties unset and listed only non-default fields as required, while the SDK's own helpers (passing the model class to parse(), or openai.pydantic_function_tool) set additionalProperties false and required on every object. The helper did not fix a model with extra='allow' or a Dict[str, int] field; both still produced a schema that breaks the documented rule.
Can I turn strict mode off instead of fixing the schema? For function tools, yes: OpenAI's function calling guide says setting strict: false keeps non-strict, best-effort function calling, so the model is no longer guaranteed to follow the schema. For response formats, the documented schema-free alternative is JSON mode, which the guide says guarantees valid JSON but not adherence to any schema.
Related
- OpenAI "model not found" error — causes & fixes
- OpenAI context_length_exceeded (400) — causes & fixes
- OpenAI API 500 error — causes & retry pattern
Verified on 9 November 2026: schema rules and limits read from OpenAI's Structured Outputs and function calling guides fetched that day; SDK schema generation inspected locally with openai 3.48.0 / pydantic 2.14.3 / Python 3.11.9 (output shown above, no API call made); the function-tool error body is quoted from OpenAI's openai-dotnet test recording, and the response_format error strings are user-reported from GitHub issues, not reproduced.