Installation
Get Memori installed and connected to your own database in a few steps.
Want a zero-setup option? The hosted platform at app.memorilabs.ai offers 100 memories free without an API key, and 5,000/month with a free API key.
Install Memori
pip install memori
Install Your Database Driver
Memori works with any database that SQLAlchemy supports, plus MongoDB. Install the driver for your preferred database:
# No extra install needed!
# SQLite support is included with Python.
Set Up Your Database Connection
Memori accepts a connection factory — a callable that returns a database connection. The most common approach is to use SQLAlchemy's sessionmaker.
- Name
conn- Type
- callable
- Required
- Required
- Description
A connection factory that Memori calls to get a database connection. For SQLAlchemy, this is your
sessionmaker. For raw DB-API 2.0 connections, pass a function that returns a connection object.
The conn parameter is the only required configuration for open-source Memori. It tells Memori where to store all memory data.
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine("sqlite:///memori.db")
SessionLocal = sessionmaker(bind=engine)
# Pass SessionLocal as the connection factory
from memori import Memori
mem = Memori(conn=SessionLocal)
Create the Schema
After setting up your connection, run build() once to create the Memori tables in your database. This only needs to be done the first time, or when you upgrade Memori.
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from memori import Memori
engine = create_engine("sqlite:///memori.db")
SessionLocal = sessionmaker(bind=engine)
mem = Memori(conn=SessionLocal)
mem.config.storage.build() # Creates all required tables
Install Your LLM Provider
Install the SDK for your preferred LLM provider:
pip install openai
Set Up Your LLM Provider Key
You will need an API key for your LLM provider:
# OpenAI
export OPENAI_API_KEY="your-openai-key"
# Anthropic
export ANTHROPIC_API_KEY="your-anthropic-key"
# Google Gemini
export GOOGLE_API_KEY="your-google-key"
Pre-download the Embedding Model
Memori uses a local embedding model for semantic search. On first run, it downloads the model automatically, which can take a moment. To pre-download it:
python -m memori setup
Verify Installation
Run a quick check to make sure everything is installed correctly:
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from memori import Memori
engine = create_engine("sqlite:///memori.db")
SessionLocal = sessionmaker(bind=engine)
mem = Memori(conn=SessionLocal)
mem.config.storage.build()
print("Memori is ready!")
Next Steps
- Continue to the Quick Start guide
- Explore Use Cases for your application
- See all supported LLM Providers and Databases