{"record":{"id":"168658d123bd0773","repo":"BerriAI/litellm","slug":"missing-google-cloud-package-run-pip-install-u","errorCode":null,"errorMessage":"Missing google.cloud package. Run `pip install --upgrade google-cloud-language`","messagePattern":"Missing google\\.cloud package\\. Run `pip install --upgrade google-cloud-language`","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"enterprise/enterprise_hooks/google_text_moderation.py","lineNumber":45,"sourceCode":"        \"death_harm_and_tragedy\",\n        \"violent\",\n        \"firearms_and_weapons\",\n        \"public_safety\",\n        \"health\",\n        \"religion_and_belief\",\n        \"illicit_drugs\",\n        \"war_and_conflict\",\n        \"politics\",\n        \"finance\",\n        \"legal\",\n    ]  # https://cloud.google.com/natural-language/docs/moderating-text#safety_attribute_confidence_scores\n\n    # Class variables or attributes\n    def __init__(self):\n        try:\n            from google.cloud import language_v1  # type: ignore\n        except Exception:\n            raise Exception(\n                \"Missing google.cloud package. Run `pip install --upgrade google-cloud-language`\"\n            )\n\n        # Instantiates a client\n        self.client = language_v1.LanguageServiceClient()\n        self.moderate_text_request = language_v1.ModerateTextRequest\n        self.language_document = language_v1.types.Document  # type: ignore\n        self.document_type = language_v1.types.Document.Type.PLAIN_TEXT  # type: ignore\n\n        default_confidence_threshold = (\n            litellm.google_moderation_confidence_threshold or 0.8\n        )  # by default require a high confidence (80%) to fail\n\n        for category in self.confidence_categories:\n            if hasattr(litellm, f\"{category}_confidence_threshold\"):\n                setattr(\n                    self,\n                    f\"{category}_confidence_threshold\",","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/enterprise_hooks/google_text_moderation.py#L27-L63","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: hook enabled but package missing\ncallbacks: [google_text_moderation]  # raises at startup\n\n# after\npip install --upgrade google-cloud-language\n# or remove the hook from config","handlingStrategy":"validation","validationCode":"try:\n    from google.cloud import language_v1  # noqa\n    google_language_available = True\nexcept ImportError:\n    google_language_available = False\n\nif not google_language_available:\n    print(\"skip google_text_moderation hook or install google-cloud-language\")","typeGuard":null,"tryCatchPattern":"try:\n        from google.cloud import language_v1  # type: ignore\n    except ImportError:\n        raise Exception(\"Missing google.cloud package. Run `pip install --upgrade google-cloud-language`\")","preventionTips":["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."],"tags":["enterprise","google-moderation","dependency","startup","pip"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}