{"record":{"id":"aa8e5f1bc9880c26","repo":"BerriAI/litellm","slug":"litellm-logging-obj-is-required-but-got-none","errorCode":null,"errorMessage":"litellm_logging_obj is required, but got None","messagePattern":"litellm_logging_obj is required, but got None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/google_genai/main.py","lineNumber":154,"sourceCode":"            api_key=litellm_params.api_key,\n        )\n\n        if litellm_params.custom_llm_provider is None:\n            litellm_params.custom_llm_provider = custom_llm_provider\n\n        # get provider config\n        generate_content_provider_config: Final[BaseGoogleGenAIGenerateContentConfig | None] = (\n            ProviderConfigManager.get_provider_google_genai_generate_content_config(\n                model=model,\n                provider=litellm.LlmProviders(custom_llm_provider),\n            )\n        )\n\n        if generate_content_provider_config is None:\n            # Use adapter to transform to completion format when provider config is None\n            # Signal that we should use the adapter by returning special result\n            if litellm_logging_obj is None:\n                raise ValueError(\"litellm_logging_obj is required, but got None\")\n            return GenerateContentSetupResult(\n                model=model,\n                custom_llm_provider=custom_llm_provider,\n                request_body={},  # Will be handled by adapter\n                generate_content_provider_config=None,\n                generate_content_config_dict=dict(config or {}),\n                native_request_fields={},\n                litellm_params=litellm_params,\n                litellm_logging_obj=litellm_logging_obj,\n                litellm_call_id=litellm_call_id,\n            )\n\n        #########################################################################################\n        # Construct request body\n        #########################################################################################\n        # Create Google Optional Params Config\n        generate_content_config_dict: Final = generate_content_provider_config.map_generate_content_optional_params(\n            generate_content_config_dict=config or {},","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/google_genai/main.py#L136-L172","documentation":"In Google GenAI generate_content setup: when no native provider config exists for the model/provider, LiteLLM falls back to the adapter path, which needs a litellm_logging_obj to run the underlying completion call with proper logging. If kwargs passed litellm_logging_obj=None on this fallback branch, setup fails immediately with ValueError.","triggerScenarios":"Calling litellm.google_genai generate_content entry points directly without a logging object while the model resolves to a provider lacking a native generate_content config (triggering the adapter branch).","commonSituations":"Bypassing the public wrapper that creates Logging; custom integrations that call _generate_content_setup-style internals; SDK refactors where the logging kwarg name changed.","solutions":["Call the public generate_content API (litellm.google_genai.generate_content / agenerate_content) which constructs litellm_logging_obj for you","If calling internals, build and pass litellm_logging_obj: Logging(model=model, stream=stream, call_type='completion')","Ensure custom_llm_provider/model resolve to a provider with a native config if you truly cannot supply a logger"],"exampleFix":"# before\nsetup = generate_content_setup(model='x', contents=c, litellm_logging_obj=None)\n\n# after\nfrom litellm.litellm_core_utils.litellm_logging import Logging\nsetup = generate_content_setup(model='x', contents=c, litellm_logging_obj=Logging('x', stream=False, call_type='completion'))","handlingStrategy":"validation","validationCode":"if calling_internals:\n    from litellm.litellm_core_utils.litellm_logging import Logging\n    kwargs[\"litellm_logging_obj\"] = kwargs.get(\"litellm_logging_obj\") or Logging(model, stream=stream, call_type=\"completion\")","typeGuard":"def has_valid_logging_obj(lo) -> bool:\n    return lo is not None and hasattr(lo, \"update_from_kwargs\")","tryCatchPattern":null,"preventionTips":["Call public generate_content entry points","Forward litellm_logging_obj in custom wrappers"],"tags":["google-genai","logging","internal-api-misuse"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}