GoogleSearchTool fails to support Gemini models accessed via OpenRouter API
Issue Description
In ADK v1.12.0, GoogleSearchTool cannot recognize Gemini models accessed through OpenRouter API, causing it to throw a "Google search tool is not supported for model" error. The same configuration worked correctly in v1.6.2.
Environment Information
- ADK Version: v1.12.0 (problematic version)
- Previously working version: v1.6.2
- Python Version: 3.10
- API Provider: OpenRouter
- Model name format:
openrouter/google/gemini-2.5-pro:online
Steps to Reproduce
- Configure Gemini model via OpenRouter API:
model = LiteLlm(
model="openrouter/google/gemini-2.5-pro:online",
api_key=os.getenv("OPENROUTER_API_KEY"),
api_base="https://openrouter.ai/api/v1"
)
- Create LlmAgent with
google_searchtool:
search_agent = LlmAgent(
name="search_agent",
model=model,
tools=[google_search]
)
- Run agent to trigger Google search tool
Actual Behavior
Throws error:
ValueError: Google search tool is not supported for model openrouter/google/gemini-2.5-pro:online
Expected Behavior
Should correctly identify this as a Gemini 2.x model and add appropriate search tool configuration.
Root Cause Analysis
The issue stems from model name parsing logic in google/adk/utils/model_name_utils.py:
Current problematic code (google_search_tool.py lines 51-59):
if is_gemini_1_model(llm_request.model):
# ...
elif is_gemini_model(llm_request.model):
# ...
else:
raise ValueError(f'Google search tool is not supported for model {llm_request.model}')
The model_name_utils.py limitation:
def extract_model_name(model_string: str) -> str:
# Only supports Google Cloud path format: projects/.../models/gemini-xxx
path_pattern = r'^projects/[^/]+/locations/[^/]+/publishers/[^/]+/models/(.+)$'
match = re.match(path_pattern, model_string)
if match:
return match.group(1)
# If not path format, return original string directly
return model_string
def is_gemini_model(model_string: Optional[str]) -> bool:
model_name = extract_model_name(model_string)
return re.match(r'^gemini-', model_name) is not None
For OpenRouter's model format "openrouter/google/gemini-2.5-pro:online":
- Doesn't match Google Cloud path pattern
- Returns original string
"openrouter/google/gemini-2.5-pro:online"directly - Regex
^gemini-check fails because string starts withopenrouter - Returns
False, causing unsupported model error
Previous working code in v1.6.2:
if llm_request.model and 'gemini-1' in llm_request.model:
# ...
elif llm_request.model and 'gemini-' in llm_request.model:
# ...
Impact Scope
This affects users accessing Gemini models through OpenRouter API and other third-party providers that use similar model naming conventions.
Related Files
google/adk/tools/google_search_tool.py(lines 51-66)google/adk/utils/model_name_utils.py(lines 23-91)
This is a backward compatibility regression that prevents using GoogleSearchTool with Gemini models accessed via OpenRouter API.
@zhanhaojia The issue is that extract_model_name() in model_name_utils.py doesn't handle provider-prefixed formats like "openrouter/google/gemini-2.5-pro:online".
Quick workaround: strip the prefix/suffix to pass just "gemini-2.5-pro" to ADK.
Thanks!
Is it fixed? I tried with with only 'gemini-2.5-pro' but it was checking the vertex ai based deployment but I am using the LiteLLM via OpenRouter..when using with the name , getting error - Google search tool is not supported for model openrouter/google/gemini-2.5-pro