{
  "id": 21721482,
  "title": "Why LLM Structured Output Strict Mode Rejects Valid JSON Schema (additionalProperties & Required Keys)",
  "url": "https://urgent.news/2026/11/25/why-llm-structured-output-strict-mode-rejects-valid-json-schema",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-25T02:34:52.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/dev_in_the_fog/why-llm-structured-output-strict-mode-rejects-valid-json-schema-additionalproperties-required-o54"
  },
  "original_language": "en",
  "account": "When transitioning from prompt-engineered JSON to strict Structured Outputs, using response_format: { type: \"json_schema\", strict: true } often results in 400 Invalid schema errors. This occurs even when the schema passes standard JSON Schema validators. Two main constraints trigger these errors: every object, including nested objects, must have additionalProperties set to false, and every key in properties must also appear in required.\n\nSetting additionalProperties: false only on the root object is insufficient. Strict mode mandates that every nested object inside properties, items, or anyOf explicitly prevents extra keys. Furthermore, optional properties cannot be omitted from required. When modeling an optional field, it must remain in required and its type should be made nullable, such as { \"type\": \"object\", \"additionalProperties\": false, \"properties\": { \"summary\": { \"type\": \"string\" }, \"errorCode\": { \"type\": [\"string\", \"null\"] } }, \"required\": [\"summary\", \"errorCode\"] }.\n\nAnother crucial consideration is the variability of format keywords (uri, custom formats, complex regex patterns) across different providers like OpenAI, Gemini, and Anthropic. Identifying strict-mode violations locally before submitting to the API can save time and effort. Tools such as openapi-zod-lint (MIT licensed, node-based), a Prompt/Structured Output Schema Converter, an LLM Token Calculator, and a cURL Converter are available to assist in this process.",
  "summary": "Switching from prompt-engineered JSON to strict Structured Outputs ( response_format: { type: \"json_schema\", strict: true } ) often triggers 400 Invalid schema errors on schemas that pass standard JSON Schema validators. Two strict-mode constraints cause almost every failure. 1. Every Object—Including Nested Ones—Needs additionalProperties: false Setting additionalProperties: false only on the…",
  "key_points": [
    "Strict Structured Outputs reject valid JSON schemas with additionalProperties set to false.",
    "Required keys must appear in required, even for optional fields, which must be nullable."
  ],
  "editors_take": "Adopting strict structured outputs forces developers to abandon standard JSON schema practices in favor of rigid constraints that mandate explicit nullability and total property declaration to ensure model reliability.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}