You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error when response schema definition has anyOf with null #625
I use v1.9.0 with the Gemini API. When sending a request with a response_schema with anyOf and where of the options is null, the API returns this error:
400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Unable to submit request because one or more response schemas specified other fields alongside any_of. When using any_of, it must be the only field set. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output', 'status': 'INVALID_ARGUMENT'}}
Is it a bug, and am I not using a non-supported schema feature?
To reproduce
In Python using this data model:
Baz=str|int|NoneclassFoo(BaseModel):
bar: Baz
I get the error whereas this data model returns no error:
Hi @DDJensMadsen@EItanya with the latest release v1.16.1 I am experiencing the opposite where VertexAI client throws validation errors for type Optional[Union[str, List[Dict[str, Any]]]] while gemini API client allows this setup. #1807
Perhaps something changed on the Gemini API since its support for json schema. Is this something you still encounter on your type str | int | None ?
Activity
EItanya commentedon May 23, 2025
I would like to double down on this. How is a user supposed to signify that a parameter is optional? Btw, this is also true for tool calls as well.
DDJensMadsen commentedon May 26, 2025
hi @EItanya I am not sure I understand your comment? Could you elaborate a bit :-)
EItanya commentedon May 26, 2025
This issue is specifically saying that response_schema incorrectly handles any_of, but I'm updating that the same problem exists for tool calls.
luutuankiet commentedon Dec 3, 2025
Hi @DDJensMadsen @EItanya with the latest release v1.16.1 I am experiencing the opposite where VertexAI client throws validation errors for type
Optional[Union[str, List[Dict[str, Any]]]]while gemini API client allows this setup. #1807Perhaps something changed on the Gemini API since its support for json schema. Is this something you still encounter on your type
str | int | None?Venkaiahbabuneelam commentedon May 21, 2026
Hi Team,
Could you please confirm whether the issue is resolved or still persists?
Thanks
github-actions commentedon May 30, 2026
This issue has been marked as stale because it has been open for 7 days with no activity. It will be closed in 2 days if no further activity occurs.
github-actions commentedon Jun 1, 2026
This issue was closed because it has been inactive for 9 days. Please post a new issue if you need further assistance. Thanks!