mem0ai/mem0 · error · ImportError

google-cloud-aiplatform is required for Vertex AI. Install w

Error message

google-cloud-aiplatform is required for Vertex AI. Install with: pip install google-cloud-aiplatform

What it means

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.

Source

Thrown at mem0/utils/gcp_auth.py:117

        """
        Initialize Vertex AI with proper authentication.

        Args:
            service_account_json: Service account credentials as dict
            credentials_path: Path to service account JSON file
            project_id: GCP project ID (optional, will be auto-detected)
            location: GCP location/region

        Returns:
            str: The project ID being used

        Raises:
            ValueError: If authentication fails
        """
        try:
            import vertexai
        except ImportError:
            raise ImportError("google-cloud-aiplatform is required for Vertex AI. Install with: pip install google-cloud-aiplatform")

        credentials, detected_project_id = GCPAuthenticator.get_credentials(
            service_account_json=service_account_json,
            credentials_path=credentials_path,
            scopes=["https://www.googleapis.com/auth/cloud-platform"]
        )

        # Use provided project_id or fall back to detected one
        final_project_id = project_id or detected_project_id or os.getenv("GOOGLE_CLOUD_PROJECT")

        if not final_project_id:
            raise ValueError("Project ID could not be determined. Please provide project_id parameter or set GOOGLE_CLOUD_PROJECT environment variable.")

        vertexai.init(project=final_project_id, location=location, credentials=credentials)
        return final_project_id

    @staticmethod
    def get_genai_client(

View on GitHub (pinned to 001c235229)

Solutions

  1. pip install google-cloud-aiplatform
  2. Or install the bundled extra: pip install 'mem0ai[google]' (if defined) / add the package to your requirements
  3. Verify: python -c "import vertexai; print(vertexai.__version__)"
  4. Ensure your Python version is supported (3.9+) and the venv is the one running your app

Example fix

# before: ImportError: google-cloud-aiplatform is required ...
from mem0 import Memory
m = Memory.from_config(cfg_with_vertexai)

# after
# pip install google-cloud-aiplatform google-auth
from mem0 import Memory
m = Memory.from_config(cfg_with_vertexai)
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
if importlib.util.find_spec('vertexai') is None:
    raise ConfigError('google-cloud-aiplatform missing — pip install google-cloud-aiplatform')

Try / catch

try:
    GCPAuthenticator.setup_vertex_ai(project_id='p', location='us-central1')
except ImportError as e:
    if 'google-cloud-aiplatform is required' in str(e):
        raise ConfigError('install google-cloud-aiplatform') from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: Partial dependency installs; upgrading mem0ai without reinstalling extras; pip resolver dropping google-cloud-aiplatform during a conflict.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/38c1d97645eb4408. Report an issue: GitHub.