The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test_gemini_url_context
Ishaan Jafferbe7ab0b3e3be
diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.pyindex cc50bc99543..d3f67967213 100644--- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py+++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py@@ -415,8 +415,8 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):googleSearchRetrieval = self.get_tool_value(tool, VertexToolName.GOOGLE_SEARCH_RETRIEVAL.value)elif tool_name and tool_name == VertexToolName.ENTERPRISE_WEB_SEARCH.value:enterpriseWebSearch = self.get_tool_value(tool, VertexToolName.ENTERPRISE_WEB_SEARCH.value)- elif tool_name and tool_name == VertexToolName.URL_CONTEXT.value:- urlContext = self.get_tool_value(tool, VertexToolName.URL_CONTEXT.value)+ elif tool_name and (tool_name == VertexToolName.URL_CONTEXT.value or tool_name == "urlContext"):+ urlContext = self.get_tool_value(tool, tool_name)elif tool_name and (tool_name == VertexToolName.GOOGLE_MAPS.value or tool_name == "google_maps"):@@ -448,9 +448,10 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):"Invalid tool={}. Use `litellm.set_verbose` or `litellm --detailed_debug` to see raw request.")- _tools = Tools(- function_declarations=gtool_func_declarations,- )+ # Only include function_declarations if there are actual functions+ _tools = Tools()+ if gtool_func_declarations:+ _tools["function_declarations"] = gtool_func_declarationsif googleSearch is not None:_tools[VertexToolName.GOOGLE_SEARCH.value] = googleSearchif googleSearchRetrieval is not None:diff --git a/tests/llm_translation/test_gemini.py b/tests/llm_translation/test_gemini.pyindex c34e59a73ec..871aebdc9fd 100644--- a/tests/llm_translation/test_gemini.py+++ b/tests/llm_translation/test_gemini.py@@ -465,11 +465,11 @@ def test_gemini_url_context():from litellm import completionlitellm._turn_on_debug()+ URL1 = "https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592"- url = "https://ai.google.dev/gemini-api/docs/models"prompt = f"""- Summarize this document:- {url}+ Get the recipes listed on the following website+ {URL1}"""response = completion(model="gemini/gemini-2.5-flash",@@ -482,7 +482,7 @@ def test_gemini_url_context():url_context_metadata = response.model_extra["vertex_ai_url_context_metadata"]assert url_context_metadata is not NoneurlMetadata = url_context_metadata[0]["urlMetadata"][0]- assert urlMetadata["retrievedUrl"] == url+ assert urlMetadata["retrievedUrl"] == URL1assert urlMetadata["urlRetrievalStatus"] == "URL_RETRIEVAL_STATUS_SUCCESS"