{"id":27453636,"url":"https://github.com/pdavies/openai-structured-outputs-schema","last_synced_at":"2026-05-09T09:47:29.123Z","repository":{"id":287961444,"uuid":"962271005","full_name":"pdavies/openai-structured-outputs-schema","owner":"pdavies","description":"Metaschema for validating OpenAI Structured Outputs schemas","archived":false,"fork":false,"pushed_at":"2025-04-14T20:40:46.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T13:56:21.864Z","etag":null,"topics":["jsonschema","jsonschema-validator","openai","openai-structured-output","structured-outputs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pdavies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-07T22:56:41.000Z","updated_at":"2025-04-14T20:40:50.000Z","dependencies_parsed_at":"2025-04-14T21:34:54.792Z","dependency_job_id":"842263a3-d1b0-4961-9c48-038942926518","html_url":"https://github.com/pdavies/openai-structured-outputs-schema","commit_stats":null,"previous_names":["pdavies/openai-structured-outputs-schema"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdavies%2Fopenai-structured-outputs-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdavies%2Fopenai-structured-outputs-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdavies%2Fopenai-structured-outputs-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdavies%2Fopenai-structured-outputs-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pdavies","download_url":"https://codeload.github.com/pdavies/openai-structured-outputs-schema/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085486,"owners_count":21210267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jsonschema","jsonschema-validator","openai","openai-structured-output","structured-outputs"],"created_at":"2025-04-15T13:56:24.330Z","updated_at":"2026-05-09T09:47:24.073Z","avatar_url":"https://github.com/pdavies.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAI Structured Outputs metaschema\n\n[OpenAI Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) ensure that model outputs conform to a JSON schema provided by the client, but it supports only a [subset](https://platform.openai.com/docs/guides/structured-outputs#supported-schemas) of JSON schemas. This repo offers a metaschema that validates a schema's conformance to many of OpenAI's constraints.\n\n## Usage\n\n\u003e [!IMPORTANT]  \n\u003e The metaschema is built on top of the 2019-09 JSON Schema spec. You may need to set up your validator appropriately, for example `import Ajv from \"ajv/dist/2019\";` rather than `import Ajv from \"ajv\";`\n\nDepending on your validator of choice, you will probably need to do the following:\n\n* Set your JSON schema's `$schema` to `\"https://pdavies.co.uk/openai-structured-outputs-schema/2019-09/schema\"`\n* Add the `https://pdavies.co.uk/openai-structured-outputs-schema/2019-09/schema`  metaschema to your validator, e.g. `ajv.addMetaSchema(...)`\n* Also add `https://pdavies.co.uk/openai-structured-outputs-schema/2019-09/innerSchema` to your validator\n\n## Validated Constraints\n\n| Constraint | Validated | Notes |\n|------------|-----------|-------|\n| Root objects must not be `anyOf` | ✅ |  |\n| All fields must be required | ⚠️ | Only validates that `required` exists and is non-empty |\n| Capped object count, nesting depth, total string size, enum size | ❌ | |\n| `additionalProperties` must be set and `false` | ✅ | |\n| String constraints not supported (`minLength`, `maxLength`, `pattern`, `format`) | ✅ | Rejected by metaschema. (OpenAI rejects when `strict: true`.) |\n| Number constraints not supported (`minimum`, `maximum`, `multipleOf`) | ✅ | As above |\n| Object constraints not supported (`patternProperties`, `unevaluatedProperties`, `propertyNames`, `minProperties`, `maxProperties`) | ✅ | As above |\n| Array constraints not supported (`unevaluatedItems`, `contains`, `minContains`, `maxContains`, `minItems`, `maxItems`, `uniqueItems`) | ✅ | As above |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdavies%2Fopenai-structured-outputs-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdavies%2Fopenai-structured-outputs-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdavies%2Fopenai-structured-outputs-schema/lists"}