BerriAI/litellm · error · ValueError

custom_llm_provider is required

Error message

custom_llm_provider is required

What it means

validate_input_kwargs in the speech-to-completion bridge raises ValueError("custom_llm_provider is required") when kwargs["custom_llm_provider"] is missing, None, or not a str. The bridge needs the provider string to route the synthesized chat-completion call (it is forwarded as custom_llm_provider to litellm.completion). Only direct/internal invocations of the handler hit this — litellm.speech() always supplies it.

Solutions

  1. Resolve the provider first with litellm.get_llm_provider(model=model) and pass its result as custom_llm_provider.
  2. Use litellm.speech(model="openai/gpt-4o-audio-preview", ...) — the "<provider>/<model>" syntax lets litellm derive and pass custom_llm_provider itself.
  3. Supply all required kwargs in one dict when calling the handler directly (see SpeechToCompletionBridgeHandlerInputKwargs).

Example fix

# before
handler.speech(model="gpt-4o-audio-preview", input="hi", voice="alloy", optional_params={}, litellm_params={}, headers={}, logging_obj=log)  # ValueError: custom_llm_provider is required

# after
_, custom_llm_provider = litellm.get_llm_provider(model="gpt-4o-audio-preview")
handler.speech(model="gpt-4o-audio-preview", input="hi", voice="alloy", optional_params={}, litellm_params={}, headers={}, logging_obj=log, custom_llm_provider=custom_llm_provider)
Defensive patterns

Strategy: validation

Validate before calling

import litellm

def resolve_provider_or_fail(model: str) -> str:
    _, provider = litellm.get_llm_provider(model=model)
    if not isinstance(provider, str) or not provider:
        raise ValueError(f"could not resolve custom_llm_provider for {model!r}")
    return provider

Type guard

def is_valid_provider_kwarg(value: object) -> bool:
    return isinstance(value, str) and len(value.strip()) > 0

Prevention

When it happens

Trigger: Calling speech_to_completion_bridge_handler.speech(...) directly without custom_llm_provider, or passing None (e.g. when get_llm_provider() failed upstream and the caller forwarded the None).

Common situations: Custom wrappers around the bridge that never resolved a provider; test harnesses building kwargs by hand; copied example code that predates the provider argument.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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


class SpeechToCompletionBridgeHandler:
    def __init__(self):
        from .transformation import SpeechToCompletionBridgeTransformationHandler

        super().__init__()
        self.transformation_handler = SpeechToCompletionBridgeTransformationHandler()

    def validate_input_kwargs(self, kwargs: dict) -> SpeechToCompletionBridgeHandlerInputKwargs:
        from litellm import LiteLLMLoggingObj

        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")

View on GitHub (pinned to 77b7c6c40c)