BerriAI/litellm · error · ValueError
litellm_logging_obj is required, but got None
Error message
litellm_logging_obj is required, but got None
What it means
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.
Source
Thrown at litellm/google_genai/main.py:154
api_key=litellm_params.api_key,
)
if litellm_params.custom_llm_provider is None:
litellm_params.custom_llm_provider = custom_llm_provider
# get provider config
generate_content_provider_config: Final[BaseGoogleGenAIGenerateContentConfig | None] = (
ProviderConfigManager.get_provider_google_genai_generate_content_config(
model=model,
provider=litellm.LlmProviders(custom_llm_provider),
)
)
if generate_content_provider_config is None:
# Use adapter to transform to completion format when provider config is None
# Signal that we should use the adapter by returning special result
if litellm_logging_obj is None:
raise ValueError("litellm_logging_obj is required, but got None")
return GenerateContentSetupResult(
model=model,
custom_llm_provider=custom_llm_provider,
request_body={}, # Will be handled by adapter
generate_content_provider_config=None,
generate_content_config_dict=dict(config or {}),
native_request_fields={},
litellm_params=litellm_params,
litellm_logging_obj=litellm_logging_obj,
litellm_call_id=litellm_call_id,
)
#########################################################################################
# Construct request body
#########################################################################################
# Create Google Optional Params Config
generate_content_config_dict: Final = generate_content_provider_config.map_generate_content_optional_params(
generate_content_config_dict=config or {},View on GitHub (pinned to 6c2dcb801b)
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
Example fix
# before
setup = generate_content_setup(model='x', contents=c, litellm_logging_obj=None)
# after
from litellm.litellm_core_utils.litellm_logging import Logging
setup = generate_content_setup(model='x', contents=c, litellm_logging_obj=Logging('x', stream=False, call_type='completion')) Defensive patterns
Strategy: validation
Validate before calling
if calling_internals:
from litellm.litellm_core_utils.litellm_logging import Logging
kwargs["litellm_logging_obj"] = kwargs.get("litellm_logging_obj") or Logging(model, stream=stream, call_type="completion") Type guard
def has_valid_logging_obj(lo) -> bool:
return lo is not None and hasattr(lo, "update_from_kwargs") Prevention
- Call public generate_content entry points
- Forward litellm_logging_obj in custom wrappers
When it happens
Trigger: 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).
Common situations: Bypassing the public wrapper that creates Logging; custom integrations that call _generate_content_setup-style internals; SDK refactors where the logging kwarg name changed.
Related errors
- logging_obj is required
- logging_obj is required
- logging_obj is required
- Failed to transform streaming response
- Error calling litellm.acompletion for generate_content: {e}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/aa8e5f1bc9880c26.
Report an issue: GitHub.