{"record":{"id":"eda78ccd394196f3","repo":"BerriAI/litellm","slug":"model-is-required-eda78c","errorCode":null,"errorMessage":"model is required","messagePattern":"model is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/endpoints/speech/speech_to_completion_bridge/handler.py","lineNumber":37,"sourceCode":"    litellm_params: dict\n    logging_obj: \"LiteLLMLoggingObj\"\n    headers: dict\n    custom_llm_provider: str\n\n\nclass SpeechToCompletionBridgeHandler:\n    def __init__(self):\n        from .transformation import SpeechToCompletionBridgeTransformationHandler\n\n        super().__init__()\n        self.transformation_handler = SpeechToCompletionBridgeTransformationHandler()\n\n    def validate_input_kwargs(self, kwargs: dict) -> SpeechToCompletionBridgeHandlerInputKwargs:\n        from litellm import LiteLLMLoggingObj\n\n        model: Final = kwargs.get(\"model\")\n        if model is None or not isinstance(model, str):\n            raise ValueError(\"model is required\")\n\n        custom_llm_provider: Final = kwargs.get(\"custom_llm_provider\")\n        if custom_llm_provider is None or not isinstance(custom_llm_provider, str):\n            raise ValueError(\"custom_llm_provider is required\")\n\n        input: Final = kwargs.get(\"input\")\n        if input is None or not isinstance(input, str):\n            raise ValueError(\"input is required\")\n\n        optional_params: Final = kwargs.get(\"optional_params\")\n        if optional_params is None or not isinstance(optional_params, dict):\n            raise ValueError(\"optional_params is required\")\n\n        litellm_params: Final = kwargs.get(\"litellm_params\")\n        if litellm_params is None or not isinstance(litellm_params, dict):\n            raise ValueError(\"litellm_params is required\")\n\n        headers = kwargs.get(\"headers\")","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/endpoints/speech/speech_to_completion_bridge/handler.py#L19-L55","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Call the public litellm.speech(...) API instead of the internal bridge handler — it assembles all required kwargs for you.","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).","Add a pre-flight isinstance(kwargs.get(\"model\"), str) assertion in your wrapper to fail with your own error message."],"exampleFix":"# before\nhandler.speech(input=\"hi\", voice=\"alloy\", optional_params={}, litellm_params={}, headers={}, logging_obj=log, custom_llm_provider=\"openai\")  # ValueError: model is required\n\n# after\nhandler.speech(model=\"gpt-4o-audio-preview\", input=\"hi\", voice=\"alloy\", optional_params={}, litellm_params={}, headers={}, logging_obj=log, custom_llm_provider=\"openai\")","handlingStrategy":"validation","validationCode":"def check_speech_kwargs(kwargs: dict) -> None:\n    if not isinstance(kwargs.get(\"model\"), str) or not kwargs[\"model\"].strip():\n        raise ValueError(\"speech bridge requires a non-empty string 'model'\")","typeGuard":"def is_valid_model_kwarg(value: object) -> bool:\n    return isinstance(value, str) and len(value.strip()) > 0","tryCatchPattern":null,"preventionTips":["Call litellm.speech() instead of the internal bridge handler — it fills in every required kwarg.","When wrapping the handler, build the full SpeechToCompletionBridgeHandlerInputKwargs TypedDict so type checkers catch omissions.","Fail fast in wrappers: assert all required keys before delegating."],"tags":["speech","tts","validation","kwargs","internal-api"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}