BerriAI/litellm · error · ValueError

litellm_params is required

Error message

litellm_params is required

What it means

Thrown by SpeechToCompletionBridgeHandler.validate_input_kwargs when 'litellm_params' is missing from kwargs or is not a dict (handler.py:53). litellm_params carries per-request metadata (api_base, api_key, metadata, etc.) injected by the router; the bridge requires it before building the completion request.

Source

Thrown at litellm/endpoints/speech/speech_to_completion_bridge/handler.py:53

        model: Final = kwargs.get("model")
        if model is None or not isinstance(model, str):
            raise ValueError("model is required")

        custom_llm_provider: Final = kwargs.get("custom_llm_provider")
        if custom_llm_provider is None or not isinstance(custom_llm_provider, str):
            raise ValueError("custom_llm_provider is required")

        input: Final = kwargs.get("input")
        if input is None or not isinstance(input, str):
            raise ValueError("input is required")

        optional_params: Final = kwargs.get("optional_params")
        if optional_params is None or not isinstance(optional_params, dict):
            raise ValueError("optional_params is required")

        litellm_params: Final = kwargs.get("litellm_params")
        if litellm_params is None or not isinstance(litellm_params, dict):
            raise ValueError("litellm_params is required")

        headers = kwargs.get("headers")
        if headers is None or not isinstance(headers, dict):
            raise ValueError("headers is required")

        headers = kwargs.get("headers")
        if headers is None or not isinstance(headers, dict):
            raise ValueError("headers is required")

        logging_obj: Final = kwargs.get("logging_obj")
        if logging_obj is None or not isinstance(logging_obj, LiteLLMLoggingObj):
            raise ValueError("logging_obj is required")

        return SpeechToCompletionBridgeHandlerInputKwargs(
            model=model,
            input=input,
            voice=kwargs.get("voice"),
            optional_params=optional_params,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Route calls through litellm.audio_speech()/litellm.speech() so the router injects litellm_params
  2. If calling the handler directly, pass litellm_params=get_litellm_params() or at minimum {}
  3. Ensure custom router patches return a dict for litellm_params

Example fix

# before
handler.speech(model=m, input=i, voice=v, optional_params={}, litellm_params=None, headers={}, logging_obj=log, custom_llm_provider="openai")

# after
from litellm import get_litellm_params
handler.speech(model=m, input=i, voice=v, optional_params={}, litellm_params=get_litellm_params(), headers={}, logging_obj=log, custom_llm_provider="openai")
Defensive patterns

Strategy: validation

Validate before calling

from litellm import get_litellm_params
litellm_params = litellm_params if isinstance(litellm_params, dict) else get_litellm_params()

Type guard

def has_litellm_params(kwargs: dict) -> bool:
    return isinstance(kwargs.get("litellm_params"), dict)

Try / catch

try:
    handler.speech(..., litellm_params=litellm_params, ...)
except ValueError as e:
    if "litellm_params is required" in str(e):
        logger.error("Call bypassed litellm routing; use litellm.audio_speech")
        raise

Prevention

When it happens

Trigger: Direct invocation of speech_to_completion_bridge_handler.speech() without litellm_params; litellm_params set to None by custom routing or mocking code.

Common situations: Bypassing litellm's standard entrypoints; test harnesses that construct kwargs manually; monkeypatched get_litellm_params returning None.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/eb44cd92c9142130. Report an issue: GitHub.