Enforce a schema to the output.
The format of the dictionary should follow JSON Schema specification.
The Google GenAI SDK automatically transforms schemas for Gemini compatibility:
$defs definitions (enables Union types with anyOf)$ref pointers for nested/recursive schemasminimum/maximum, minItems/maxItemsUnion types in Pydantic models (e.g., field: Union[TypeA, TypeB]) are
automatically converted to anyOf schemas and work correctly with the
json_schema method.
Refer to the Gemini API docs for more details on supported JSON Schema features.