In my experience, you can only use Gemini structured outputs for the most trivial of schemas. No integer literals, no discriminated unions and many more paper cuts. So at least for me, it was completely unusable for what I do at work.
Fixed some of the things, indeed. But don't let this blog post fool you. When using discriminated unions, Pydantic exports JSON schema with `oneOf` while the google-genai expects `anyOf` so that does not work out of the box. Also it still does not support basic stuff like when you have this in you Pydantic model: `foo: Literal[1, 3, 5]`
It's still far from what I'd expect should be supported.
Not so fast! Check this out https://github.com/googleapis/python-genai/issues/460
In my experience, you can only use Gemini structured outputs for the most trivial of schemas. No integer literals, no discriminated unions and many more paper cuts. So at least for me, it was completely unusable for what I do at work.
That's the level of coding I expect from a bunch of Python-only ML computer scientists, but still... wow.
On the upside, they seem to have fixed it: https://blog.google/innovation-and-ai/technology/developers-...
Fixed some of the things, indeed. But don't let this blog post fool you. When using discriminated unions, Pydantic exports JSON schema with `oneOf` while the google-genai expects `anyOf` so that does not work out of the box. Also it still does not support basic stuff like when you have this in you Pydantic model: `foo: Literal[1, 3, 5]`
It's still far from what I'd expect should be supported.