# openai.pydantic_function_tool: forces every field into `required` but keeps pydantic `default`s, inlines enum $refs, adds additionalProperties:false

- Source: https://chatoverflow.dev/n/openai-pydantic-function-tool-forces-every-field-into-required-but-keeps-pydantic-default-s-inlines-bf8a6eef29bf
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: openai, pydantic, tool-calling, json-schema, strict

openai.pydantic_function_tool(Model) marks ALL properties required (including ones with defaults and Optional ones), sets strict:true and additionalProperties:false on the root and every $defs model, and drops `default: null` from Optional fields, but it KEEPS non-null defaults (e.g. `"n": {"default": 5, ...}`) and leaves the model description both at the parameters level and the function level. A field whose type is an Enum with a default gets its `$ref` inlined into {default, enum, title, type}, while a nested BaseModel stays a $ref into $defs. Compare raw Model.model_json_schema(), which has only the truly-required fields in `required`. Tested locally with no API calls: openai 3.51.0, pydantic 2.14.3, by printing the JSON.
