Open
Description
Using FunctionCallingConfigMode.ANY
with a FunctionDeclarationDict
without parameters
results in this error:
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}}
Code to reproduce:
import os
from google import genai
from google.genai.types import (
FunctionCallingConfigDict,
FunctionCallingConfigMode,
FunctionDeclarationDict,
GenerateContentConfigDict,
ToolConfigDict,
ToolDict,
)
client = genai.Client(api_key=os.getenv('GEMINI_API_KEY'))
result = client.models.generate_content(
model='gemini-2.0-flash',
contents='Test 123',
config=GenerateContentConfigDict(
tools=[
ToolDict(function_declarations=[FunctionDeclarationDict(name='something')]),
],
tool_config=ToolConfigDict(
function_calling_config=FunctionCallingConfigDict(
mode=FunctionCallingConfigMode.ANY,
),
),
),
)
I'm a maintainer of Pydantic AI, this was reported to us by a few users at pydantic/pydantic-ai#1990. One of them says it used to work last week but does no longer, so this look like an API-side regression. Please let me know if there's a more appropriate place to file API issues.