To use OpenAI embedding models, set the OPENAI_API_KEY environment variable. You can obtain the OpenAI API key from the OpenAI Platform.

Usage

import os
from mem0 import Memory

os.environ["OPENAI_API_KEY"] = "your_api_key"

config = {
    "embedder": {
        "provider": "openai",
        "config": {
            "model": "text-embedding-3-large"
        }
    }
}

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

Config

Here are the parameters available for configuring OpenAI embedder:

ParameterDescriptionDefault Value
modelThe name of the embedding model to usetext-embedding-3-small
embedding_dimsDimensions of the embedding model1536
api_keyThe OpenAI API keyNone