BerriAI/litellm · error · ValueError

search_provider not found in litellm_params for search tool

Error message

search_provider not found in litellm_params for search tool '{search_tool_name}'

What it means

Config guard in the search API router: the selected search tool entry has no search_provider key in its litellm_params, so the router cannot determine which provider handler to invoke for it.

Source

Thrown at litellm/router_utils/search_api_router.py:212

        """
        search_tool_name: Final = model  # model field contains the search_tool_name

        try:
            # Find matching search tools
            matching_tools: Final = SearchAPIRouter.get_matching_search_tools(
                router_instance=router_instance,
                search_tool_name=search_tool_name,
            )

            # Simple random selection for load balancing across multiple providers with same name
            # For search tools, we use simple random choice since they don't have TPM/RPM constraints
            selected_tool: Final = random.choice(matching_tools)

            # Extract search provider and other params from litellm_params
            litellm_params: Final = selected_tool.get("litellm_params", {})
            search_provider: Final = litellm_params.get("search_provider")
            if not search_provider:
                raise ValueError(f"search_provider not found in litellm_params for search tool '{search_tool_name}'")

            api_key, api_base = SearchAPIRouter._resolve_search_provider_credentials(
                tool_litellm_params=litellm_params,
            )

            verbose_router_logger.debug("Selected search tool with provider: %s", search_provider)

            # Call the original search function with the provider config
            response: Final = await original_generic_function(
                search_provider=search_provider,
                api_key=api_key,
                api_base=api_base,
                **kwargs,
            )

            return response

        except Exception as e:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Add search_provider to the search tool's litellm_params.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/router_utils/search_api_router.py:212 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/731c3b7ea1490833. Report an issue: GitHub.