{"record":{"id":"d6740269236c999e","repo":"BerriAI/litellm","slug":"optional-params-is-required-d67402","errorCode":null,"errorMessage":"optional_params is required","messagePattern":"optional_params is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/endpoints/speech/speech_to_completion_bridge/handler.py","lineNumber":49,"sourceCode":"\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\")\n        if headers is None or not isinstance(headers, dict):\n            raise ValueError(\"headers is required\")\n\n        headers = kwargs.get(\"headers\")\n        if headers is None or not isinstance(headers, dict):\n            raise ValueError(\"headers is required\")\n\n        logging_obj: Final = kwargs.get(\"logging_obj\")\n        if logging_obj is None or not isinstance(logging_obj, LiteLLMLoggingObj):\n            raise ValueError(\"logging_obj is required\")\n\n        return SpeechToCompletionBridgeHandlerInputKwargs(","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/endpoints/speech/speech_to_completion_bridge/handler.py#L31-L67","documentation":"validate_input_kwargs in the speech-to-completion bridge raises ValueError(\"optional_params is required\") when kwargs[\"optional_params\"] is missing, None, or not a dict. optional_params carries per-request options (response_format, etc.); transform_request filters it against OPENAI_CHAT_COMPLETION_PARAMS and folds the survivors into the completion call (transformation.py:24-26).","triggerScenarios":"Calling the bridge handler directly with optional_params omitted or set to None; forwarding a non-dict such as a list of params or a JSON string.","commonSituations":"Custom integrations that only pass the fields they consider relevant; refactors where optional_params was renamed; defaults of None leaking from config loaders.","solutions":["Always pass a dict, even an empty one: handler.speech(..., optional_params={}, ...).","If your options arrive as a JSON string, parse first: optional_params=json.loads(raw).","Prefer litellm.speech(), which constructs optional_params from its own keyword arguments."],"exampleFix":"# before\nhandler.speech(model=\"gpt-4o-audio-preview\", input=\"hi\", voice=\"alloy\", litellm_params={}, headers={}, logging_obj=log, custom_llm_provider=\"openai\")  # ValueError: optional_params 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_optional_params(kwargs: dict) -> None:\n    if not isinstance(kwargs.get(\"optional_params\"), dict):\n        raise ValueError(\"speech bridge requires dict 'optional_params' (use {} if none)\")","typeGuard":"def is_valid_optional_params(value: object) -> bool:\n    return isinstance(value, dict)","tryCatchPattern":null,"preventionTips":["Default optional_params to {} in wrapper signatures: def speak(..., optional_params: dict | None = None): optional_params = optional_params or {}.","Parse JSON strings to dicts before forwarding.","Prefer litellm.speech(), which constructs optional_params from keyword arguments."],"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"}