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 root object is not enough. Structured Output engines compile a constrained grammar ahead of decoding, so every nested object inside properties, items, or anyOf must explicitly forbid extra keys.
2. Optional Properties Cannot Be Omitted From required
In strict mode, every key in properties must appear in required. To model an optional field, keep it in required and make its type nullable:
{
"type": "object",
"additionalProperties": false,
"properties": {
"summary": { "type": "string" },
"errorCode": { "type": ["string", "null"] }
},
"required": ["summary", "errorCode"]
}
3. Cross-Provider Format Quirks
Format keywords (uri, custom formats, complex regex pattern) behave differently across OpenAI, Gemini, and Anthropic. Catching strict-mode violations locally before hitting the API saves trial-and-error cycles.
Local CLI & Zero-Upload Browser Tools
-
Open-Source CLI (
openapi-zod-lint, MIT,node --testpassing): https://github.com/JangYS0/openapi-zod-lint - Prompt / Structured Output Schema Converter (0B upload): https://global-utils.com/en/prompt-schema-converter
- LLM Token Calculator: https://global-utils.com/en/llm-token-calculator
- cURL Converter (client-side): https://global-utils.com/en/curl-converter
Top comments (0)