{"record":{"id":"1bd51652d8b5b55c","repo":"BerriAI/litellm","slug":"headers-is-required","errorCode":null,"errorMessage":"headers is required","messagePattern":"headers is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/handler.py","lineNumber":130,"sourceCode":"        custom_llm_provider: Final = typed_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        messages: Final = typed_kwargs.get(\"messages\")\n        if messages is None or not isinstance(messages, list):\n            raise ValueError(\"messages is required\")\n\n        optional_params: Final = typed_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 = typed_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: Final = typed_kwargs.get(\"headers\")\n        if headers is None or not isinstance(headers, dict):\n            raise ValueError(\"headers is required\")\n\n        model_response: Final = typed_kwargs.get(\"model_response\")\n        if model_response is None or not isinstance(model_response, ModelResponse):\n            raise ValueError(\"model_response is required\")\n\n        logging_obj: Final = typed_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 ResponsesToCompletionBridgeHandlerInputKwargs(\n            model=model,\n            messages=messages,\n            optional_params=optional_params,\n            litellm_params=litellm_params,\n            headers=headers,\n            model_response=model_response,\n            logging_obj=logging_obj,\n            custom_llm_provider=custom_llm_provider,","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/handler.py#L112-L148","documentation":"validate_input_kwargs raises when 'headers' is missing from kwargs or is not a dict. The bridge forwards request headers (auth, org id, extra headers) to the Responses API call. In the standard pipeline headers are always initialized as a dict before the handler runs, so this fires only on direct/manual invocations.","triggerScenarios":"Direct bridge handler call with a kwargs dict lacking the headers key; headers passed as None.","commonSituations":"Hand-built kwargs in custom routers or proxies; older code written against a handler version that defaulted headers instead of requiring them.","solutions":["Call litellm.completion so headers default to {} internally","If direct, include headers={}","Ensure extra_headers config is merged into the dict, not passed separately"],"exampleFix":"# before\nkwargs = {\"model\": m, \"messages\": msgs, \"litellm_params\": {}}\n\n# after\nkwargs = {\"model\": m, \"messages\": msgs, \"litellm_params\": {}, \"headers\": {}}","handlingStrategy":"validation","validationCode":"def has_headers_kwarg(kwargs: dict) -> bool:\n    return isinstance(kwargs.get(\"headers\"), dict)","typeGuard":"def is_dict_param(v) -> bool:\n    return isinstance(v, dict)","tryCatchPattern":null,"preventionTips":["Default headers to {} when building kwargs","Merge extra_headers into the dict rather than passing a separate object"],"tags":["validation","bridge","headers","internal-api"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}