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]

[Bug Fix]: Search APIs - error in firecrawl-search "Invalid request body" (#16943)

Ishaan Jaffed6c3b4c864b
diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml
index 2e58d8554c6..014bcdc1670 100644
--- a/litellm/proxy/proxy_config.yaml
+++ b/litellm/proxy/proxy_config.yaml
@@ -26,10 +26,10 @@ search_tools:
litellm_params:
search_provider: perplexity
api_key: os.environ/PERPLEXITYAI_API_KEY
- - search_tool_name: exa-search
+ - search_tool_name: firecrawl-search
litellm_params:
- search_provider: exa_ai
- api_key: os.environ/EXA_API_KEY
+ search_provider: firecrawl
+ api_key: os.environ/FIRECRAWL_API_KEY
litellm_settings:
diff --git a/litellm/types/utils.py b/litellm/types/utils.py
index 6e34bbca3aa..10b7e42b5d2 100644
--- a/litellm/types/utils.py
+++ b/litellm/types/utils.py
@@ -2478,6 +2478,7 @@ all_litellm_params = (
"use_litellm_proxy",
"prompt_label",
"shared_session",
+ "search_tool_name",
]
+ list(StandardCallbackDynamicParams.__annotations__.keys())
+ list(CustomPricingLiteLLMParams.model_fields.keys())
diff --git a/tests/search_tests/test_search_tool_name_filtering.py b/tests/search_tests/test_search_tool_name_filtering.py
new file mode 100644
index 00000000000..2cfe1177b43
--- /dev/null
+++ b/tests/search_tests/test_search_tool_name_filtering.py
@@ -0,0 +1,50 @@
+"""
+Test that search_tool_name is properly filtered out from search requests.
+
+The search_tool_name parameter is used internally by LiteLLM to identify
+which search tool configuration to use, but should not be sent to external
+search provider APIs.
+"""
+import sys
+import os
+
+sys.path.insert(0, os.path.abspath("../.."))
+
+from litellm.types.utils import all_litellm_params
+from litellm.utils import filter_out_litellm_params
+
+
+def test_search_tool_name_in_all_litellm_params():
+ """
+ Test that search_tool_name is in all_litellm_params.
+
+ If missing, it gets passed to provider APIs causing errors.
+ """
+ assert "search_tool_name" in all_litellm_params
+
+
+def test_filter_out_search_tool_name():
+ """
+ Test that filter_out_litellm_params correctly filters search_tool_name.
+ """
+ kwargs = {
+ "query": "latest ai developments",
+ "max_results": 5,
+ "scrapeOptions": {"formats": ["markdown"]},
+ "search_tool_name": "firecrawl-search",
+ "metadata": {"user": "test"},
+ "litellm_call_id": "test-123"
+ }
+
+ filtered = filter_out_litellm_params(kwargs=kwargs)
+
+ assert "search_tool_name" not in filtered
+ assert "metadata" not in filtered
+ assert "litellm_call_id" not in filtered
+
+ assert "query" in filtered
+ assert "max_results" in filtered
+ assert "scrapeOptions" in filtered
+ assert filtered["query"] == "latest ai developments"
+ assert filtered["max_results"] == 5
+