BerriAI/litellm · error · ValueError

input is required

Error message

input is required

What it means

Thrown by SpeechToCompletionBridgeHandler.validate_input_kwargs when 'input' is missing from kwargs or is not a str (handler.py:45). 'input' is the text to synthesize; the bridge validates it must be a plain string before transforming the request into a chat/completions payload.

Source

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

        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")
        if headers is None or not isinstance(headers, dict):
            raise ValueError("headers is required")

        logging_obj: Final = kwargs.get("logging_obj")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass the text to synthesize as the input= string argument
  2. If your text arrives as bytes or a list, convert/join it to a str before calling
  3. Check the proxy /v1/audio/speech request body uses the 'input' field with a string value

Example fix

# before
resp = litellm.audio_speech(model="gpt-4o-audio-preview", voice="alloy", input=None)

# after
resp = litellm.audio_speech(model="gpt-4o-audio-preview", voice="alloy", input="Hello world")
Defensive patterns

Strategy: validation

Validate before calling

if not isinstance(text, str) or not text:
    raise ValueError("input text is required for speech synthesis")
resp = litellm.audio_speech(model=model, input=text, voice=voice)

Type guard

def is_speech_input_valid(text: object) -> bool:
    return isinstance(text, str) and len(text) > 0

Try / catch

try:
    resp = litellm.audio_speech(model=model, input=text, voice=voice)
except ValueError as e:
    if "input is required" in str(e):
        return bad_request_response("'input' must be a non-empty string")

Prevention

When it happens

Trigger: Calling the TTS bridge with input=None, input omitted, or input as a non-string (list of messages, bytes, dict). Direct handler invocation without the input argument.

Common situations: Passing a chat-style messages list to a speech endpoint; dynamically built requests where the text field key is named 'text' or 'prompt' instead of 'input'; empty request bodies on the proxy.

Related errors


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