{"record":{"id":"a94fef76044ade6d","repo":"BerriAI/litellm","slug":"logging-obj-is-required","errorCode":null,"errorMessage":"logging_obj is required","messagePattern":"logging_obj is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/handler.py","lineNumber":138,"sourceCode":"        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,\n            encoding=typed_kwargs.get(\"encoding\"),\n        )\n\n    def completion(\n        self, *args, **kwargs\n    ) -> Union[\n        Coroutine[Any, Any, Union[\"ModelResponse\", \"CustomStreamWrapper\"]],\n        \"ModelResponse\",","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/handler.py#L120-L156","documentation":"validate_input_kwargs raises when 'logging_obj' is missing or is not a LiteLLMLoggingObj. The bridge needs the logging object for success/failure logging and to recover raw SSE data when the completed response has empty output. It is created by litellm's logging pipeline in every supported entry point.","triggerScenarios":"Calling the bridge handler without logging_obj, or passing a mock/None; disabling logging in a fork by dropping the key instead of passing a no-op logger.","commonSituations":"Direct handler use; test doubles that bypass generate_base_llm_response; custom proxies that strip logging objects.","solutions":["Call litellm.completion/acompletion which generates the logging object automatically","If direct, create one via litellm.litellm_core_utils.litellm_logging.LoggingHandler / LiteLLMLoggingObj before invoking","Do not strip logging_obj when wrapping the pipeline; pass it through unchanged"],"exampleFix":"# before\nkwargs = {..., \"logging_obj\": None}\n\n# after\nfrom litellm.litellm_core_utils.litellm_logging import LoggingHandler\nlogger = LoggingHandler(model=\"gpt-4o\", messages=msgs, stream=False, litellm_call_id=\"x\", function_id=\"y\")\nkwargs = {..., \"logging_obj\": logger}","handlingStrategy":"validation","validationCode":"def has_logging_obj(kwargs: dict) -> bool:\n    return kwargs.get(\"logging_obj\") is not None and hasattr(kwargs[\"logging_obj\"], \"post_call\")","typeGuard":"def is_logging_obj(v) -> bool:\n    import litellm\n    return isinstance(v, litellm.LiteLLMLoggingObj)","tryCatchPattern":null,"preventionTips":["Always thread the pipeline-created logging object through wrappers","In tests, patch at the transport layer instead of stripping logging_obj"],"tags":["validation","bridge","logging","internal-api"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}