transitive-bullshit/openai-zod-to-json-schema(新しいタブで開きます)
主要言語: TypeScript
Convert Zod schemas to JSON schemas which are optionally compatible with OpenAI's structured outputs.
- star 数
- 21
- watcher 数
- 1
- fork 数
- 1
- issue 数
- 1
- 最終更新
- 2025/07/19
主要言語: TypeScript
Convert Zod schemas to JSON schemas which are optionally compatible with OpenAI's structured outputs.
Convert Zod schemas to JSON schemas which are optionally compatible with OpenAI's structured outputs.
This package exports OpenAI's vendored version of zod-to-json-schema as a standalone module (the source code is copied directly to guarantee a 1:1 match).
It re-adds all of the unit tests from the original zod-to-json-schema by Stefan Terdell.
It also adds some additional unit tests for OpenAI's strict mode. See OpenAI's docs on structured outputs for more details on the subset of JSON Schemas that are supported by OpenAI's structured outputs.
This package will be kept in sync with any changes to OpenAI's vendored version.
Note
This package requires Node.js >= 18 or an equivalent environment (Bun, Deno, CF workers, etc).
npm install openai-zod-to-json-schema zod
All usage is the same as the original zod-to-json-schema, with the addition of a single optional boolean option: openaiStrictMode.
import { zodToJsonSchema } from 'openai-zod-to-json-schema' import { z } from 'zod' const schema = zodToJsonSchema(z.any(), { openaiStrictMode: true })
zod-to-json-schema without depending on the entire openai package.zod-to-json-schema removed all unit tests for some reason, which could cause undesired regressions.zod-to-json-schema for openai-fetch, dexter, and agentic.MIT © Travis Fischer
Also see the original zod-to-json-schema license.