diff --git a/litellm/router_utils/search_api_router.py b/litellm/router_utils/search_api_router.py index c83c7c35ef9..260bb4cc03a 100644 --- a/litellm/router_utils/search_api_router.py +++ b/litellm/router_utils/search_api_router.py @@ -37,14 +37,8 @@ class SearchAPIRouter: Returns: Tuple of (api_key, api_base) from tool configuration """ - from litellm.secret_managers.main import get_secret_str - resolved_api_key: Optional[str] = tool_litellm_params.get("api_key") resolved_api_base: Optional[str] = tool_litellm_params.get("api_base") - if isinstance(resolved_api_key, str) and resolved_api_key.startswith("os.environ/"): - resolved_api_key = get_secret_str(resolved_api_key) - if isinstance(resolved_api_base, str) and resolved_api_base.startswith("os.environ/"): - resolved_api_base = get_secret_str(resolved_api_base) return resolved_api_key, resolved_api_base diff --git a/tests/e2e/llm_translation/test_search_e2e.py b/tests/e2e/llm_translation/test_search_e2e.py index 84e4e572704..9268a37a011 100644 --- a/tests/e2e/llm_translation/test_search_e2e.py +++ b/tests/e2e/llm_translation/test_search_e2e.py @@ -21,7 +21,6 @@ pytestmark = pytest.mark.e2e class SearchToolLiteLLMParams(BaseModel): search_provider: str - api_key: str class SearchToolBody(BaseModel): @@ -56,17 +55,16 @@ class SearchResponse(BaseModel): results: list[SearchResultItem] = [] -def _search_credentials() -> tuple[str, str]: +def _search_provider() -> str: if os.environ.get("PERPLEXITY_API_KEY") or os.environ.get("PERPLEXITYAI_API_KEY"): - env_name = "PERPLEXITY_API_KEY" if os.environ.get("PERPLEXITY_API_KEY") else "PERPLEXITYAI_API_KEY" - return "perplexity", f"os.environ/{env_name}" + return "perplexity" if os.environ.get("TAVILY_API_KEY"): - return "tavily", "os.environ/TAVILY_API_KEY" + return "tavily" pytest.fail("set PERPLEXITY_API_KEY or TAVILY_API_KEY for /v1/search e2e coverage") def _register_search_tool(proxy: ProxyClient, resources: ResourceManager) -> str: - provider, api_key = _search_credentials() + provider = _search_provider() name = f"e2e-search-{unique_marker()}" created = unwrap( proxy.transport.post( @@ -75,9 +73,7 @@ def _register_search_tool(proxy: ProxyClient, resources: ResourceManager) -> str json=CreateSearchToolRequest( search_tool=SearchToolBody( search_tool_name=name, - litellm_params=SearchToolLiteLLMParams( - search_provider=provider, api_key=api_key - ), + litellm_params=SearchToolLiteLLMParams(search_provider=provider), search_tool_info={"description": "e2e search tool"}, ) ), diff --git a/tests/test_litellm/router_utils/test_search_api_router.py b/tests/test_litellm/router_utils/test_search_api_router.py deleted file mode 100644 index 901701db9ea..00000000000 --- a/tests/test_litellm/router_utils/test_search_api_router.py +++ /dev/null @@ -1,43 +0,0 @@ -from litellm.router_utils.search_api_router import SearchAPIRouter - - -def test_resolve_search_provider_credentials_expands_os_environ_refs( - monkeypatch, -) -> None: - monkeypatch.setenv("E2E_SEARCH_API_KEY", "secret-from-env") - monkeypatch.setenv("E2E_SEARCH_API_BASE", "https://search.example") - - api_key, api_base = SearchAPIRouter._resolve_search_provider_credentials( - tool_litellm_params={ - "api_key": "os.environ/E2E_SEARCH_API_KEY", - "api_base": "os.environ/E2E_SEARCH_API_BASE", - } - ) - - assert api_key == "secret-from-env" - assert api_base == "https://search.example" - - -def test_resolve_search_provider_credentials_passes_through_plain_values() -> None: - api_key, api_base = SearchAPIRouter._resolve_search_provider_credentials( - tool_litellm_params={ - "api_key": "sk-literal", - "api_base": "https://literal.example", - } - ) - - assert api_key == "sk-literal" - assert api_base == "https://literal.example" - - -def test_resolve_search_provider_credentials_missing_env_returns_none( - monkeypatch, -) -> None: - monkeypatch.delenv("MISSING_SEARCH_KEY_XYZ", raising=False) - - api_key, api_base = SearchAPIRouter._resolve_search_provider_credentials( - tool_litellm_params={"api_key": "os.environ/MISSING_SEARCH_KEY_XYZ"} - ) - - assert api_key is None - assert api_base is None