Hi,
I got following error when trying the function call with gemini 2 Python SDK:
“response parameter is not supported in Google AI.”
Here is the code that defines the function call
my_func_call = types.FunctionDeclaration(
name="test_func",
description="Test func ...",
parameters={ ...
},
response={
"type": "OBJECT",
"properties": { ... },
},
},
)
The SDK definition of types.FunctionDeclaration is
class FunctionDeclaration(_common.BaseModel):
"""Defines a function that the model can generate JSON inputs for.
The inputs are based on `OpenAPI 3.0 specifications
<https://spec.openapis.org/oas/v3.0.3>`_.
"""
response: Optional[Schema] = Field(
default=None,
description="""Describes the output from the function in the OpenAPI JSON Schema
Object format.""",
)
....
)
The invocation code is:
resp = client.models.generate_content(
model="gemini-2.0-flash-exp",
contents=prompt,
config=types.GenerateContentConfig(
tools=[my_func_call],
),
)
Does anyone have success with defining response schema for a function call in the new 2.0 API?
Thanks