BerriAI/litellm · error · ValueError

Got an unexpected None response from the Search API: {respon

Error message

Got an unexpected None response from the Search API: {response}

What it means

Result guard in the search API: the provider-specific search call completed but returned None instead of a SearchResponse (provider adapter bug or empty upstream payload); the raw response is included for debugging.

Source

Thrown at litellm/search/main.py:148

            country=country,
            api_key=api_key,
            api_base=api_base,
            timeout=timeout,
            extra_headers=extra_headers,
            **kwargs,
        )

        ctx: Final = contextvars.copy_context()
        func_with_context: Final = partial(ctx.run, func)
        init_response: Final = await loop.run_in_executor(None, func_with_context)

        if asyncio.iscoroutine(init_response):
            response = await init_response
        else:
            response = init_response

        if response is None:
            raise ValueError(f"Got an unexpected None response from the Search API: {response}")

        return response
    except Exception as e:
        model_name: Final = f"{search_provider}/search"
        raise litellm.exception_type(
            model=model_name,
            custom_llm_provider=search_provider,
            original_exception=e,
            completion_kwargs=local_vars,
            extra_kwargs=kwargs,
        )


@client
def search(
    query: str | list[str],
    search_provider: str,
    max_results: int | None = None,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Retry the search; if persistent, check provider credentials and litellm debug logs for why None was returned.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/search/main.py:148 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/607361b40e933078. Report an issue: GitHub.