OpenAI schema error
Fix an OpenAI tool schema with anyOf at the root
Replace an unsupported root anyOf with an object-root discriminated contract that OpenAI Structured Outputs accepts.
OpenAI supports anyOf inside a schema, but the root must be an object and cannot itself be anyOf. Move the choice into a named property and add a discriminator.
Read the schema and its provider wrapper as one contract. APITC distinguishes target requirements from portable JSON Schema, applies mechanical repairs only when intent is recoverable, and identifies transformations that can change meaning.
Diagnostic procedure
Repair the schema, then recompile.
- 01
Create an object root
Use a stable outer object so every call has one predictable argument envelope.
- 02
Nest the alternatives
Put anyOf under a property such as action or payload.
- 03
Add a discriminator
Give each branch an enum or const-like action field so the model can select intentionally.
{"anyOf":[{"type":"object","properties":{"email":{"type":"string"}}},{"type":"object","properties":{"id":{"type":"string"}}}]}{"type":"object","properties":{"lookup":{"anyOf":[{"type":"object","properties":{"email":{"type":"string"}},"required":["email"],"additionalProperties":false},{"type":"object","properties":{"id":{"type":"string"}},"required":["id"],"additionalProperties":false}]}},"required":["lookup"],"additionalProperties":false}$.inputSchemaClose this objectOpenAI strict requires additionalProperties: false on every object.
$.inputSchemaRequired array is incompleteStrict mode requires every property in required. APITC will make limit nullable.
No account · no upload · no endpoint calledOpen the full tool schema compiler and operating notes →
FAQ
Before you ship
Does APITC upload my schema?
No. Parsing, diagnostics, and compilation run in your browser tab.
Is the compiled result guaranteed to preserve meaning?
Safe repairs are deterministic. When OpenAI cannot express a source constraint, APITC labels the transform as lossy instead of hiding it.
Protocol behavior checked against the OpenAI Structured Outputs guide. Recheck your pinned provider/API version before production deployment.