{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/endpoints/speech/speech_to_completion_bridge/handler.py#L39-L75","documentation":"validate_input_kwargs in the speech-to-completion bridge raises ValueError(\"headers is required\") when kwargs[\"headers\"] is missing, None, or not a dict. headers (incoming request headers) are forwarded into the completion call (transformation.py:45) so auth and client hints survive the bridge. This is the FIRST of two identical checks (lines 55-57 and 59-61) — this instance is the one that actually fires.","triggerScenarios":"Calling the bridge handler directly without a headers argument; passing headers=None; passing an httpx.Headers object instead of a plain dict.","commonSituations":"Standalone scripts adapted from proxy code where headers came from the inbound request; passing httpx.Headers instead of dict(headers); test kwargs omitting the field.","solutions":["Pass a plain dict, even empty: handler.speech(..., headers={}, ...).","Convert httpx objects: headers=dict(httpx_headers).","Route through litellm.speech(), which supplies headers from its standard path."],"exampleFix":"# before\nhandler.speech(model=\"gpt-4o-audio-preview\", input=\"hi\", voice=\"alloy\", optional_params={}, litellm_params={}, logging_obj=log, custom_llm_provider=\"openai\")  # ValueError: headers is required\n\n# after\nhandler.speech(model=\"gpt-4o-audio-preview\", input=\"hi\", voice=\"aloy\".replace(\"aloy\", \"alloy\"), optional_params={}, litellm_params={}, headers={}, logging_obj=log, custom_llm_provider=\"openai\")","handlingStrategy":"validation","validationCode":"def check_headers(kwargs: dict) -> None:\n    if not isinstance(kwargs.get(\"headers\"), dict):\n        raise ValueError(\"speech bridge requires plain dict 'headers' (use {} or dict(httpx.Headers(...)))\")","typeGuard":"def is_valid_headers_kwarg(value: object) -> bool:\n    return isinstance(value, dict)","tryCatchPattern":null,"preventionTips":["Normalize httpx.Headers to dict(headers) before forwarding.","Default headers to {} in wrapper signatures.","Remember two identical checks exist (lines 57 and 61) — don't key error handling on the line number."],"tags":["speech","tts","validation","kwargs","internal-api","duplicate-code"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}