Intro
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 | None
class Foo(BaseModel):
bar: Baz
I get the error whereas this data model returns no error:
Baz = str | None
class Foo(BaseModel):
bar: Baz
I configure the Gemini client as:
GenerateContentConfig(
response_mime_type=(
"application/json"
if json_mode or json_mode_model is not None
else None
),
response_schema=response_schema,
)
and make the request as:
response = await self._client.aio.models.generate_content(
config=config,
....)
Intro
I use v1.9.0 with the Gemini API. When sending a request with a
response_schemawithanyOfand where of the options is null, the API returns this error:Is it a bug, and am I not using a non-supported schema feature?
To reproduce
In Python using this data model:
I get the error whereas this data model returns no error:
I configure the Gemini client as:
and make the request as: