To use Gemini embedding models, set the GOOGLE_API_KEY environment variables. You can obtain the Gemini API key from here.

Usage

import os
from mem0 import Memory

os.environ["GOOGLE_API_KEY"] = "key"
os.environ["OPENAI_API_KEY"] = "your_api_key" # For LLM

config = {
    "embedder": {
        "provider": "gemini",
        "config": {
            "model": "models/text-embedding-004",
        }
    }
}

m = Memory.from_config(config)
m.add("I'm visiting Paris", user_id="john")

Config

Here are the parameters available for configuring Gemini embedder:

ParameterDescriptionDefault Value
modelThe name of the embedding model to usemodels/text-embedding-004
embedding_dimsDimensions of the embedding model768
api_keyThe Gemini API keyNone