{"record":{"id":"38c1d97645eb4408","repo":"mem0ai/mem0","slug":"google-cloud-aiplatform-is-required-for-vertex-ai","errorCode":null,"errorMessage":"google-cloud-aiplatform is required for Vertex AI. Install with: pip install google-cloud-aiplatform","messagePattern":"google-cloud-aiplatform is required for Vertex AI\\. Install with: pip install google-cloud-aiplatform","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"mem0/utils/gcp_auth.py","lineNumber":117,"sourceCode":"        \"\"\"\n        Initialize Vertex AI with proper authentication.\n\n        Args:\n            service_account_json: Service account credentials as dict\n            credentials_path: Path to service account JSON file\n            project_id: GCP project ID (optional, will be auto-detected)\n            location: GCP location/region\n\n        Returns:\n            str: The project ID being used\n\n        Raises:\n            ValueError: If authentication fails\n        \"\"\"\n        try:\n            import vertexai\n        except ImportError:\n            raise ImportError(\"google-cloud-aiplatform is required for Vertex AI. Install with: pip install google-cloud-aiplatform\")\n\n        credentials, detected_project_id = GCPAuthenticator.get_credentials(\n            service_account_json=service_account_json,\n            credentials_path=credentials_path,\n            scopes=[\"https://www.googleapis.com/auth/cloud-platform\"]\n        )\n\n        # Use provided project_id or fall back to detected one\n        final_project_id = project_id or detected_project_id or os.getenv(\"GOOGLE_CLOUD_PROJECT\")\n\n        if not final_project_id:\n            raise ValueError(\"Project ID could not be determined. Please provide project_id parameter or set GOOGLE_CLOUD_PROJECT environment variable.\")\n\n        vertexai.init(project=final_project_id, location=location, credentials=credentials)\n        return final_project_id\n\n    @staticmethod\n    def get_genai_client(","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/utils/gcp_auth.py#L99-L135","documentation":"Raised inside GCPAuthenticator.setup_vertex_ai when importing the vertexai package fails. The method needs google-cloud-aiplatform to call vertexai.init(); if it is absent the ImportError is re-raised with the pip install hint. This is independent of authentication — it fails before any credential check.","triggerScenarios":"Configuring the Vertex AI embedder or vertex_ai_vector_search store on a machine with google-auth installed but google-cloud-aiplatform missing; installing only a subset of the Google extras; python version not supported by the pinned aiplatform SDK.","commonSituations":"Partial dependency installs; upgrading mem0ai without reinstalling extras; pip resolver dropping google-cloud-aiplatform during a conflict.","solutions":["pip install google-cloud-aiplatform","Or install the bundled extra: pip install 'mem0ai[google]' (if defined) / add the package to your requirements","Verify: python -c \"import vertexai; print(vertexai.__version__)\"","Ensure your Python version is supported (3.9+) and the venv is the one running your app"],"exampleFix":"# before: ImportError: google-cloud-aiplatform is required ...\nfrom mem0 import Memory\nm = Memory.from_config(cfg_with_vertexai)\n\n# after\n# pip install google-cloud-aiplatform google-auth\nfrom mem0 import Memory\nm = Memory.from_config(cfg_with_vertexai)","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('vertexai') is None:\n    raise ConfigError('google-cloud-aiplatform missing — pip install google-cloud-aiplatform')","typeGuard":null,"tryCatchPattern":"try:\n    GCPAuthenticator.setup_vertex_ai(project_id='p', location='us-central1')\nexcept ImportError as e:\n    if 'google-cloud-aiplatform is required' in str(e):\n        raise ConfigError('install google-cloud-aiplatform') from e\n    raise","preventionTips":["Install google-cloud-aiplatform whenever vertexai providers are configured","Verify imports in the build stage of CI/Docker","Track both google-auth and google-cloud-aiplatform in requirements"],"tags":["dependencies","gcp","vertex-ai","import"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}