Skip to main content

Vertex AI

Google Cloud’s Vertex AI serves text embedding models such as gemini-embedding-001. Mem0 uses them through the provider’s own SDK, which you install alongside Mem0.

Installation

The Vertex AI client is an optional dependency, so install it yourself.

Authentication

Both SDKs authenticate with Application Default Credentials. Pick whichever fits your environment:
  • Local development: run gcloud auth application-default login.
  • Service account: create a key in the Google Cloud Console and point GOOGLE_APPLICATION_CREDENTIALS at the JSON file, or pass its path through the embedder config.
  • Google Cloud runtimes (Cloud Run, GKE, Compute Engine): the attached service account is picked up automatically.
The TypeScript SDK reads the project ID from googleProjectId, then the GCP_PROJECT_ID, GOOGLE_CLOUD_PROJECT, and GCLOUD_PROJECT environment variables, and finally from your credentials. Set it explicitly when your credentials cover more than one project.

Usage

Embedding types

Vertex AI embeds the same text differently depending on the task you declare. The embedding types can be one of the following:
  • SEMANTIC_SIMILARITY
  • CLASSIFICATION
  • CLUSTERING
  • RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY, QUESTION_ANSWERING, FACT_VERIFICATION
  • CODE_RETRIEVAL_QUERY
Check out the Vertex AI documentation for more information.
These embedding types map to the add, update, and search memory actions in both the Python and TypeScript SDKs. Stored memories use the add or update type, and searches use the search type.

Choosing a model

gemini-embedding-001 accepts one input text per request. When Mem0 embeds several texts at once, such as the memories extracted from a single conversation turn, it issues one request per text. The older text-embedding-005 and text-multilingual-embedding-002 models accept up to 250 texts per request, so they are faster and cheaper for large batches. See Get text embeddings.

Config

Here are the parameters available for configuring the Vertex AI embedder: