Skip to main content

Usage

To use Google Cloud Vertex AI Vector Search with mem0, you need to configure the vector_store in your mem0 config:
import os
from mem0 import Memory

os.environ["GOOGLE_API_KEY"] = "sk-xx"

config = {
    "vector_store": {
        "provider": "vertex_ai_vector_search",
        "config": {
            "endpoint_id": "YOUR_ENDPOINT_ID",            # Required: Vector Search endpoint ID
            "index_id": "YOUR_INDEX_ID",                  # Required: Vector Search index ID
            "deployment_index_id": "YOUR_DEPLOYMENT_INDEX_ID",  # Required: Deployment-specific ID
            "project_id": "YOUR_PROJECT_ID",              # Required: Google Cloud project ID
            "project_number": "YOUR_PROJECT_NUMBER",      # Required: Google Cloud project number
            "region": "YOUR_REGION",                      # Required: Google Cloud region
            "credentials_path": "path/to/credentials.json", # Optional: Defaults to GOOGLE_APPLICATION_CREDENTIALS
            "vector_search_api_endpoint": "YOUR_API_ENDPOINT" # Required for get operations
        }
    }
}
m = Memory.from_config(config)
m.add("Your text here", user_id="user", metadata={"category": "example"})
import { Memory } from "mem0ai/oss";

// Authenticate with GOOGLE_APPLICATION_CREDENTIALS in your environment,
// or pass credentialsPath / serviceAccountJson in the config below.
const config = {
  vectorStore: {
    provider: "vertex_ai_vector_search",
    config: {
      endpointId: "YOUR_ENDPOINT_ID", // Required: Vector Search endpoint ID
      indexId: "YOUR_INDEX_ID", // Required: Vector Search index ID
      deploymentIndexId: "YOUR_DEPLOYMENT_INDEX_ID", // Required: Deployment-specific ID
      projectId: "YOUR_PROJECT_ID", // Required: Google Cloud project ID
      projectNumber: "YOUR_PROJECT_NUMBER", // Required: Google Cloud project number
      region: "YOUR_REGION", // Required: Google Cloud region
      credentialsPath: "path/to/credentials.json", // Optional: defaults to GOOGLE_APPLICATION_CREDENTIALS
      vectorSearchApiEndpoint: "YOUR_API_ENDPOINT", // Required for search/get operations
    },
  },
};

const memory = new Memory(config);
await memory.add("Your text here", {
  userId: "user",
  metadata: { category: "example" },
});

Required Parameters

ParameterDescriptionRequired
endpoint_idVector Search endpoint IDYes
index_idVector Search index IDYes
deployment_index_idDeployment-specific index IDYes
project_idGoogle Cloud project IDYes
project_numberGoogle Cloud project numberYes
vector_search_api_endpointVector search API endpointYes (for get operations)
regionGoogle Cloud regionYes
credentials_pathPath to service account credentialsNo (defaults to GOOGLE_APPLICATION_CREDENTIALS)
service_account_jsonService account credentials as a dictionary (alternative to credentials_path)None