{"record":{"id":"1eeebb341c9b7b7f","repo":"mem0ai/mem0","slug":"google-genai-is-required-install-with-pip-instal","errorCode":null,"errorMessage":"google-genai is required. Install with: pip install google-genai","messagePattern":"google-genai is required\\. Install with: pip install google-genai","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"mem0/utils/gcp_auth.py","lineNumber":154,"sourceCode":"        service_account_json: Optional[Dict[str, Any]] = None,\n        credentials_path: Optional[str] = None,\n        api_key: Optional[str] = None\n    ):\n        \"\"\"\n        Get a Google GenAI client with authentication.\n\n        Args:\n            service_account_json: Service account credentials as dict\n            credentials_path: Path to service account JSON file\n            api_key: API key (takes precedence over service account)\n\n        Returns:\n            Google GenAI client instance\n        \"\"\"\n        try:\n            from google.genai import Client as GenAIClient\n        except ImportError:\n            raise ImportError(\"google-genai is required. Install with: pip install google-genai\")\n\n        # If API key is provided, use it directly\n        if api_key:\n            return GenAIClient(api_key=api_key)\n\n        # Otherwise, try service account authentication\n        credentials, _ = GCPAuthenticator.get_credentials(\n            service_account_json=service_account_json,\n            credentials_path=credentials_path,\n            scopes=[\"https://www.googleapis.com/auth/generative-language\"]\n        )\n\n        return GenAIClient(credentials=credentials)","sourceCodeStart":136,"sourceCodeEnd":167,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/utils/gcp_auth.py#L136-L167","documentation":"Raised by GCPAuthenticator.get_genai_client when the google.genai package (the new Google GenAI SDK) cannot be imported. The method needs google.genai.Client to build the client; its absence aborts before authentication. Older google-generativeai packages do not satisfy this import.","triggerScenarios":"Using a Gemini/GenAI provider that routes through get_genai_client while only google-generativeai (the legacy SDK) is installed; fresh env with no Google SDKs; version drift where google-genai was never added to requirements.","commonSituations":"Migrating from the deprecated google-generativeai SDK and assuming it covers google.genai; Docker images built before the codebase switched to the new SDK; pip installing generativeai instead of genai.","solutions":["pip install google-genai","Add google-genai (not google-generativeai) to requirements.txt","Verify: python -c \"from google.genai import Client\"","Rebuild Docker/CI images after updating dependencies"],"exampleFix":"# before: ImportError: google-genai is required ...\nclient = GCPAuthenticator.get_genai_client(api_key=key)\n\n# after\n# pip install google-genai\nclient = GCPAuthenticator.get_genai_client(api_key=key)","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('google.genai') is None:\n    raise ConfigError('google-genai missing — pip install google-genai (not google-generativeai)')","typeGuard":null,"tryCatchPattern":"try:\n    client = GCPAuthenticator.get_genai_client(api_key=key)\nexcept ImportError as e:\n    if 'google-genai is required' in str(e):\n        raise ConfigError('install google-genai') from e\n    raise","preventionTips":["google-genai (new SDK) is a different package from google-generativeai (legacy)","Declare google-genai in requirements when using Gemini via service account","Add import smoke tests to CI"],"tags":["dependencies","gcp","gemini","import"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}