BerriAI/litellm · error · ValueError

model is required

Error message

model is required

What it means

SpeechToCompletionBridgeHandler.validate_input_kwargs (litellm/endpoints/speech/speech_to_completion_bridge/handler.py:32) type-checks every kwarg passed to the bridge that converts /speech (TTS) requests into chat-completion requests. It raises ValueError("model is required") when kwargs["model"] is missing, None, or not a str. In normal litellm.speech() flows the value is always present, so this fires almost exclusively when calling the handler directly, subclassing it, or in tests with hand-built kwargs.

Solutions

  1. Call the public litellm.speech(...) API instead of the internal bridge handler — it assembles all required kwargs for you.
  2. If you must call the handler, pass the full SpeechToCompletionBridgeHandlerInputKwargs shape: model (str), input (str), voice, optional_params (dict), litellm_params (dict), headers (dict), logging_obj (LiteLLMLoggingObj), custom_llm_provider (str).
  3. Add a pre-flight isinstance(kwargs.get("model"), str) assertion in your wrapper to fail with your own error message.

Example fix

# before
handler.speech(input="hi", voice="alloy", optional_params={}, litellm_params={}, headers={}, logging_obj=log, custom_llm_provider="openai")  # ValueError: model is required

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

Strategy: validation

Validate before calling

def check_speech_kwargs(kwargs: dict) -> None:
    if not isinstance(kwargs.get("model"), str) or not kwargs["model"].strip():
        raise ValueError("speech bridge requires a non-empty string 'model'")

Type guard

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

Prevention

When it happens

Trigger: Invoking speech_to_completion_bridge_handler.speech(...) or validate_input_kwargs(kwargs) directly with a kwargs dict that omits "model" or passes a non-string (e.g. None from an unset config, or a dict/model object). Mocking litellm internals in tests without supplying all TypedDict fields.

Common situations: Custom integrations that wrap the speech bridge instead of litellm.speech(); test fixtures built from partial dicts; refactors that rename the model field before forwarding kwargs.

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/eda78ccd394196f3. Report an issue: GitHub.

Appendix: source

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

    litellm_params: dict
    logging_obj: "LiteLLMLoggingObj"
    headers: dict
    custom_llm_provider: str


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

View on GitHub (pinned to 77b7c6c40c)