{"record":{"id":"001f58aff74a3d86","repo":"BerriAI/litellm","slug":"logging-obj-is-required-001f58","errorCode":null,"errorMessage":"logging_obj is required","messagePattern":"logging_obj is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/endpoints/speech/speech_to_completion_bridge/handler.py","lineNumber":65,"sourceCode":"        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,\n        )\n\n    def speech(\n        self,\n        model: str,\n        input: str,\n        voice: str | dict | None,\n        optional_params: dict,","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/endpoints/speech/speech_to_completion_bridge/handler.py#L47-L83","documentation":"validate_input_kwargs in the speech-to-completion bridge raises ValueError(\"logging_obj is required\") when kwargs[\"logging_obj\"] is missing, None, or not an instance of litellm.LiteLLMLoggingObj. The logging object is forwarded into the completion call (transformation.py:46) so the bridged request is tracked like any other litellm call; a plain dict, Mock, or None all fail the isinstance check.","triggerScenarios":"Calling the handler directly with logging_obj omitted or None; passing a unittest.mock.Mock or a dataclass stand-in instead of a real Logging object; constructing kwargs in tests where the import was skipped.","commonSituations":"Test suites mocking everything except logging_obj; custom server adapters that never create a Logging object; older code written against a handler version that tolerated None.","solutions":["Create and pass a real logging object: from litellm.litellm_core_utils.logging_handler import LoggingObject (litellm.LiteLLMLoggingObj) and instantiate it per the current signature.","Simplest path: call litellm.speech()/litellm.completion() so litellm constructs the logging object internally.","In tests, patch litellm.completion and construct one genuine LiteLLMLoggingObj rather than a bare Mock."],"exampleFix":"# before\nhandler.speech(model=\"gpt-4o-audio-preview\", input=\"hi\", voice=\"alloy\", optional_params={}, litellm_params={}, headers={}, custom_llm_provider=\"openai\")  # ValueError: logging_obj is required\n\n# after\nfrom litellm.litellm_core_utils.logging_handler import LoggingObject\nlog_obj = LoggingObject(user_identifier=\"\", call_type=\"speech\", litellm_params={}, kwargs={})\nhandler.speech(model=\"gpt-4o-audio-preview\", input=\"hi\", voice=\"alloy\", optional_params={}, litellm_params={}, headers={}, logging_obj=log_obj, custom_llm_provider=\"openai\")","handlingStrategy":"validation","validationCode":"from litellm import LiteLLMLoggingObj\n\ndef check_logging_obj(kwargs: dict) -> None:\n    if not isinstance(kwargs.get(\"logging_obj\"), LiteLLMLoggingObj):\n        raise ValueError(\"speech bridge requires a real LiteLLMLoggingObj instance\")","typeGuard":"from litellm import LiteLLMLoggingObj\n\ndef is_valid_logging_obj(value: object) -> bool:\n    return isinstance(value, LiteLLMLoggingObj)","tryCatchPattern":null,"preventionTips":["Construct a genuine LoggingObject (litellm.LiteLLMLoggingObj) rather than Mocks or dicts.","Delegate to litellm.speech()/completion() so litellm builds the logging object.","In tests, patch litellm.completion instead of faking the logging object."],"tags":["speech","tts","validation","kwargs","internal-api","logging"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}