BerriAI/litellm · error · Exception
Missing google.cloud package. Run `pip install --upgrade goo
Error message
Missing google.cloud package. Run `pip install --upgrade google-cloud-language`
What it means
Thrown by _ENTERPRISE_GoogleTextModeration.__init__ when importing google.cloud.language_v1 fails, meaning the google-cloud-language package is not installed in the proxy's Python environment. The hook cannot construct its LanguageServiceClient without it, so initialization aborts with an actionable install hint.
Source
Thrown at enterprise/enterprise_hooks/google_text_moderation.py:45
"death_harm_and_tragedy",
"violent",
"firearms_and_weapons",
"public_safety",
"health",
"religion_and_belief",
"illicit_drugs",
"war_and_conflict",
"politics",
"finance",
"legal",
] # https://cloud.google.com/natural-language/docs/moderating-text#safety_attribute_confidence_scores
# Class variables or attributes
def __init__(self):
try:
from google.cloud import language_v1 # type: ignore
except Exception:
raise Exception(
"Missing google.cloud package. Run `pip install --upgrade google-cloud-language`"
)
# Instantiates a client
self.client = language_v1.LanguageServiceClient()
self.moderate_text_request = language_v1.ModerateTextRequest
self.language_document = language_v1.types.Document # type: ignore
self.document_type = language_v1.types.Document.Type.PLAIN_TEXT # type: ignore
default_confidence_threshold = (
litellm.google_moderation_confidence_threshold or 0.8
) # by default require a high confidence (80%) to fail
for category in self.confidence_categories:
if hasattr(litellm, f"{category}_confidence_threshold"):
setattr(
self,
f"{category}_confidence_threshold",View on GitHub (pinned to 6c2dcb801b)
Solutions
- Run pip install --upgrade google-cloud-language in the exact environment the proxy runs in.
- Add google-cloud-language to the deployment's requirements/Dockerfile so rebuilds keep it.
- Verify with: python -c "from google.cloud import language_v1; print('ok')" as the proxy user.
- If the hook is unwanted, remove google_text_moderation from the callbacks/hooks config instead.
Example fix
# before: hook enabled but package missing callbacks: [google_text_moderation] # raises at startup # after pip install --upgrade google-cloud-language # or remove the hook from config
Defensive patterns
Strategy: validation
Validate before calling
try:
from google.cloud import language_v1 # noqa
google_language_available = True
except ImportError:
google_language_available = False
if not google_language_available:
print("skip google_text_moderation hook or install google-cloud-language") Try / catch
try:
from google.cloud import language_v1 # type: ignore
except ImportError:
raise Exception("Missing google.cloud package. Run `pip install --upgrade google-cloud-language`") Prevention
- Pin google-cloud-language in the deployment's requirements next to litellm.
- Add a CI step importing google.cloud.language_v1 when the hook is configured.
- Build Docker images with the extra included, not installed ad hoc at runtime.
- Fail builds that reference the hook without the dependency.
When it happens
Trigger: Adding the google_text_moderation hook to the proxy config on an environment where `pip install google-cloud-language` was never run, or a venv/container image that omits the optional dependency.
Common situations: Enabling Google Text Moderation in enterprise config on a stock litellm installation (the package is optional); upgrading or rebuilding Docker images that prune optional extras; mixed Python environments where the proxy runs in a different venv than the one where the package was installed.
Related errors
- File not found. blocked_user_list={blocked_user_list}
- An error occurred: {str(e)}, blocked_user_list={blocked_user
- Violated content safety policy. Category={category}
- model_name not set for LlamaGuard
- File not found. file_path={file_path}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/168658d123bd0773.
Report an issue: GitHub.