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] Exa Search API - ensure request params are sent to Exa AI (#15855)

Ishaan Jaff6d947d7326d4
diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml
index e311aac341c..c727d14dc99 100644
--- a/litellm/proxy/proxy_config.yaml
+++ b/litellm/proxy/proxy_config.yaml
@@ -17,4 +17,7 @@ search_tools:
litellm_params:
search_provider: perplexity
api_key: os.environ/PERPLEXITYAI_API_KEY
-
+ - search_tool_name: exa-search
+ litellm_params:
+ search_provider: exa_ai
+ api_key: os.environ/EXA_API_KEY
diff --git a/litellm/search/main.py b/litellm/search/main.py
index 02b5e960097..c87694e70f5 100644
--- a/litellm/search/main.py
+++ b/litellm/search/main.py
@@ -15,7 +15,7 @@ from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLogging
from litellm.llms.base_llm.search.transformation import BaseSearchConfig, SearchResponse
from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandler
from litellm.types.utils import SearchProviders
-from litellm.utils import ProviderConfigManager, client
+from litellm.utils import ProviderConfigManager, client, filter_out_litellm_params
####### ENVIRONMENT VARIABLES ###################
base_llm_http_handler = BaseLLMHTTPHandler()
@@ -263,13 +263,12 @@ def search(
country=country,
)
- # Internal LiteLLM parameters that should not be passed to providers
- litellm_internal_params = {"litellm_call_id", "litellm_logging_obj", "litellm_params"}
+ # Filter out internal LiteLLM parameters from kwargs
+ filtered_kwargs = filter_out_litellm_params(kwargs=kwargs)
# Add remaining kwargs to optional_params (for provider-specific params)
- # Filter out internal LiteLLM parameters
- for key, value in kwargs.items():
- if key not in optional_params and key not in litellm_internal_params:
+ for key, value in filtered_kwargs.items():
+ if key not in optional_params:
optional_params[key] = value
verbose_logger.debug(f"Search optional_params: {optional_params}")
diff --git a/litellm/utils.py b/litellm/utils.py
index f1e56954fe1..b1a0b13e776 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -3057,6 +3057,32 @@ def _remove_unsupported_params(
return non_default_params
+def filter_out_litellm_params(kwargs: dict) -> dict:
+ """
+ Filter out LiteLLM internal parameters from kwargs dict.
+
+ Returns a new dict containing only non-LiteLLM parameters that should be
+ passed to external provider APIs.
+
+ Args:
+ kwargs: Dictionary that may contain LiteLLM internal parameters
+
+ Returns:
+ Dictionary with LiteLLM internal parameters filtered out
+
+ Example:
+ >>> kwargs = {"query": "test", "shared_session": session_obj, "metadata": {}}
+ >>> filtered = filter_out_litellm_params(kwargs)
+ >>> # filtered = {"query": "test"}
+ """
+
+ return {
+ key: value
+ for key, value in kwargs.items()
+ if key not in all_litellm_params
+ }
+
+
class PreProcessNonDefaultParams:
@staticmethod
def base_pre_process_non_default_params(
diff --git a/tests/test_litellm/test_filter_out_litellm_params.py b/tests/test_litellm/test_filter_out_litellm_params.py
new file mode 100644
index 00000000000..9a5bc3c4e5e
--- /dev/null
+++ b/tests/test_litellm/test_filter_out_litellm_params.py
@@ -0,0 +1,36 @@
+"""
+Test filter_out_litellm_params helper function.
+"""
+from litellm.utils import filter_out_litellm_params
+
+
+def test_filter_out_litellm_params():
+ """
+ Test that filter_out_litellm_params removes LiteLLM internal parameters
+ while keeping provider-specific parameters.
+ """
+ kwargs = {
+ "query": "test query",
+ "max_results": 10,
+ "shared_session": "mock_session_object",
+ "metadata": {"key": "value"},
+ "litellm_trace_id": "trace-123",
+ "proxy_server_request": {"url": "http://example.com"},
+ "secret_fields": {"api_key": "secret"},
+ "custom_param": "should_be_kept",
+ }
+
+ filtered = filter_out_litellm_params(kwargs=kwargs)
+
+ # Provider-specific params are kept
+ assert filtered["query"] == "test query"
+ assert filtered["max_results"] == 10
+ assert filtered["custom_param"] == "should_be_kept"
+
+ # LiteLLM internal params are removed
+ assert "shared_session" not in filtered
+ assert "metadata" not in filtered
+ assert "litellm_trace_id" not in filtered
+ assert "proxy_server_request" not in filtered
+ assert "secret_fields" not in filtered
+