Skip to content

feat: expose to_strict_json_schema as public API#3196

Open
lrg913427-dot wants to merge 1 commit intoopenai:mainfrom
lrg913427-dot:feat/expose-json-schema
Open

feat: expose to_strict_json_schema as public API#3196
lrg913427-dot wants to merge 1 commit intoopenai:mainfrom
lrg913427-dot:feat/expose-json-schema

Conversation

@lrg913427-dot
Copy link
Copy Markdown

Summary

Exposes the internal to_strict_json_schema function as a public API so users can generate strict JSON schemas from Pydantic models without relying on private module paths (e.g., openai.lib._pydantic).

Changes

  • src/openai/lib/__init__.py - Added to_strict_json_schema export
  • src/openai/__init__.py - Added to_strict_json_schema to top-level exports (accessible via openai.to_strict_json_schema)
  • tests/lib/test_pydantic.py - Added test verifying public API accessibility

Motivation

Closes #2093. Users currently need to import from openai.lib._pydantic (a private module) to access to_strict_json_schema. This PR makes it a first-class public API, accessible as openai.to_strict_json_schema, following the same pattern as openai.pydantic_function_tool.

Expose the internal to_strict_json_schema function as a public API
so users can generate strict JSON schemas from Pydantic models
without relying on private module paths.

Changes:
- Add to_strict_json_schema export to openai.lib.__init__
- Add to_strict_json_schema export to openai.__init__
- Add test for public API accessibility

Closes openai#2093
@lrg913427-dot lrg913427-dot requested a review from a team as a code owner May 2, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BaseModel to jsonschema for Structured Outputs

1 participant