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
_add_web_search_tool
Ishaan Jaffer9fe0819e7782
diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.pyindex 44006f79fe3..57bd05124aa 100644--- a/litellm/completion_extras/litellm_responses_transformation/transformation.py+++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py@@ -744,13 +744,18 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge):if "tools" not in responses_api_request or responses_api_request["tools"] is None:responses_api_request["tools"] = []+ # Get the tools list with proper type narrowing+ tools = responses_api_request["tools"]+ if tools is None:+ tools = []+ responses_api_request["tools"] = tools+web_search_tool: Dict[str, Any] = {"type": "web_search"}if isinstance(web_search_options, dict):web_search_tool.update(web_search_options)- # After the check above, tools is guaranteed to be a list# Cast to Any to match the expected union type for tools list items- responses_api_request["tools"].append(cast(Any, web_search_tool))+ tools.append(cast(Any, web_search_tool))def _transform_response_format_to_text_format(self, response_format: Union[Dict[str, Any], Any]