Skip to content

Conversation

@LuminaX-alt
Copy link
Owner

…amples`) from JSON Schema in response_format

Fix Invalid Schema Error for Pydantic models with examples in response_format

  • Added a helper _strip_unsupported_keywords to recursively remove unsupported JSON Schema keywords (e.g., examples) from Pydantic-generated schemas.
  • Applied this cleanup inside normalize_response_format() to ensure only OpenAI-supported JSON Schema keywords are sent.
  • Resolves API errors when using Pydantic v2 models with examples fields.

Fixes: openai#2274

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Additional context & links

…amples`) from JSON Schema in response_format

Fix Invalid Schema Error for Pydantic models with `examples` in response_format

- Added a helper `_strip_unsupported_keywords` to recursively remove unsupported 
  JSON Schema keywords (e.g., `examples`) from Pydantic-generated schemas.
- Applied this cleanup inside `normalize_response_format()` to ensure only 
  OpenAI-supported JSON Schema keywords are sent.
- Resolves API errors when using Pydantic v2 models with `examples` fields.

Fixes: openai#2274
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.

Invalid Schema Error when Using examples Field in Pydantic Model for OpenAI Python Client

2 participants