Skip to content

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]

Add chat completion tool format

Sameer Kankute6207bf8f6856
diff --git a/litellm/integrations/websearch_interception/tools.py b/litellm/integrations/websearch_interception/tools.py
index 4f8b7372fe3..c92c66f41ee 100644
--- a/litellm/integrations/websearch_interception/tools.py
+++ b/litellm/integrations/websearch_interception/tools.py
@@ -55,6 +55,7 @@ def is_web_search_tool(tool: Dict[str, Any]) -> bool:
Detects:
- LiteLLM standard: name == "litellm_web_search"
+ - OpenAI format: type == "function" with function.name == "litellm_web_search"
- Anthropic native: type starts with "web_search_" (e.g., "web_search_20250305")
- Claude Code: name == "web_search" with a type field
- Custom: name == "WebSearch" (legacy format)
@@ -68,15 +69,25 @@ def is_web_search_tool(tool: Dict[str, Any]) -> bool:
Example:
>>> is_web_search_tool({"name": "litellm_web_search"})
True
+ >>> is_web_search_tool({"type": "function", "function": {"name": "litellm_web_search"}})
+ True
>>> is_web_search_tool({"type": "web_search_20250305", "name": "web_search"})
True
>>> is_web_search_tool({"name": "calculator"})
False
"""
+ print(f"🔥tool: {tool}")
tool_name = tool.get("name", "")
tool_type = tool.get("type", "")
-
- # Check for LiteLLM standard tool
+
+ # Check for OpenAI format: {"type": "function", "function": {"name": "..."}}
+ if tool_type == "function" and "function" in tool:
+ function_def = tool.get("function", {})
+ function_name = function_def.get("name", "")
+ if function_name == LITELLM_WEB_SEARCH_TOOL_NAME:
+ return True
+
+ # Check for LiteLLM standard tool (Anthropic format)
if tool_name == LITELLM_WEB_SEARCH_TOOL_NAME:
return True