{"record":{"id":"c5e894a175b1774a","repo":"BerriAI/litellm","slug":"headers-is-required-c5e894","errorCode":null,"errorMessage":"headers is required","messagePattern":"headers is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/endpoints/speech/speech_to_completion_bridge/handler.py","lineNumber":57,"sourceCode":"        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(\n            model=model,\n            input=input,\n            voice=kwargs.get(\"voice\"),\n            optional_params=optional_params,\n            litellm_params=litellm_params,\n            logging_obj=logging_obj,\n            custom_llm_provider=custom_llm_provider,\n            headers=headers,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/endpoints/speech/speech_to_completion_bridge/handler.py#L39-L75","documentation":"Thrown by SpeechToCompletionBridgeHandler.validate_input_kwargs when 'headers' is absent from kwargs or is not a dict (handler.py:57 — first of the duplicated checks). headers carries the inbound request headers forwarded to the provider; the bridge requires a dict (empty is acceptable). Note lines 55-61 contain a duplicated identical check; only the first can ever raise.","triggerScenarios":"Direct invocation of speech_to_completion_bridge_handler.speech() without headers; headers passed as None or as an httpx.Headers object instead of a plain dict.","commonSituations":"Custom integrations calling the handler directly and omitting headers; passing httpx.Headers or a werkzeug EnvironHeaders object where a dict is expected.","solutions":["Call through litellm.audio_speech() so headers are normalized to a dict","If invoking the handler directly, pass headers={} or dict(request.headers)"],"exampleFix":"# before\nhandler.speech(model=m, input=i, voice=v, optional_params={}, litellm_params={}, headers=None, logging_obj=log, custom_llm_provider=\"openai\")\n\n# after\nhandler.speech(model=m, input=i, voice=v, optional_params={}, litellm_params={}, headers={}, logging_obj=log, custom_llm_provider=\"openai\")","handlingStrategy":"validation","validationCode":"headers = dict(headers) if headers is not None else {}\n# httpx.Headers and other mapping types become plain dicts","typeGuard":"def is_headers_dict(headers: object) -> bool:\n    return isinstance(headers, dict)","tryCatchPattern":"try:\n    handler.speech(..., headers=headers, ...)\nexcept ValueError as e:\n    if \"headers is required\" in str(e):\n        headers = dict(inbound_headers or {})\n        # retry with normalized headers","preventionTips":["Normalize httpx.Headers / EnvironHeaders to dict before passing","Default headers to {} when none exist","Route through litellm.audio_speech() to avoid manual kwargs assembly"],"tags":["validation","tts","headers","dead-code"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}