Skip to main content

Installation

Get Memori installed and connected to your own database in a few steps.
Want a zero-setup option? Try Memori Cloud at app.memorilabs.ai.

Install Memori

pip install memori

Install Your Database Driver

Memori supports SQLite, PostgreSQL, MySQL, MariaDB, Oracle, MongoDB, CockroachDB, and OceanBase. Managed services like Neon, Supabase, and AWS RDS/Aurora work through their compatible PostgreSQL/MySQL engines. Install the driver for your preferred database:
# No extra install needed!
# SQLite support is included with Python.
Neon, Supabase, and AWS RDS/Aurora use standard PostgreSQL drivers (psycopg2-binary or psycopg).

Connection Patterns

Memori accepts a conn parameter — a callable that returns a new connection each time it is called.
PatternWhat to pass to connWorks With
SQLAlchemysessionmakerSQLite, PostgreSQL, MySQL, MariaDB, Oracle, CockroachDB, OceanBase
DB API 2.0Function that returns a PEP 249 connectionSQLite and SQL drivers (sqlite3, psycopg2, pymysql, oracledb)
Django ORMDjango connection callableDjango applications
MongoDBFunction that returns a MongoDB database objectMongoDB via pymongo

SQLite (DB API 2.0)

import sqlite3

def get_connection():
    return sqlite3.connect("memori.db")

from memori import Memori
mem = Memori(conn=get_connection)

PostgreSQL (SQLAlchemy)

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

engine = create_engine(
    "postgresql+psycopg2://user:password@localhost:5432/mydb"
)
SessionLocal = sessionmaker(bind=engine)

from memori import Memori
mem = Memori(conn=SessionLocal)

PostgreSQL (DB API 2.0)

import psycopg2
from memori import Memori

def get_connection():
    return psycopg2.connect(
        dbname="mydb",
        user="user",
        password="password",
        host="localhost",
        port=5432,
    )

mem = Memori(conn=get_connection)

MySQL / MariaDB (SQLAlchemy)

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

engine = create_engine(
    "mysql+pymysql://user:password@localhost:3306/mydb"
)
SessionLocal = sessionmaker(bind=engine)

from memori import Memori
mem = Memori(conn=SessionLocal)

MongoDB

from pymongo import MongoClient
from memori import Memori

client = MongoClient("mongodb://localhost:27017")

def get_db():
    return client["memori_db"]

mem = Memori(conn=get_db)

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.
import sqlite3
from memori import Memori

def get_connection():
    return sqlite3.connect("memori.db")

mem = Memori(conn=get_connection)
mem.config.storage.build()  # Creates all required tables
The build() method creates tables like memori_conversation_message, memori_entity_fact, memori_knowledge_graph, and more.

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"

Set Up Your Memori API Key (Optional)

A Memori API key unlocks higher augmentation quotas (5,000/month vs 100 without a key). You can sign up directly from the CLI:
python -m memori sign-up [email protected]
Then set the key as an environment variable:
export MEMORI_API_KEY="your-api-key-here"
Or add it to a .env file in your project root:
MEMORI_API_KEY=your-api-key-here
Check your current quota anytime:
python -m memori quota

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 the following command to confirm the package is installed:
pip show memori
You should see output showing the Memori package version and location.

What’s Next?

1

Quick Start

Build your first memory-enabled application with SQLite in under 3 minutes.Go to Quick Start →
2

Choose Your Database

Explore detailed setup guides for each supported database.Go to Databases →
3

Choose Your LLM

Explore integration guides for different LLM providers.View LLM integrations in the sidebar

Build docs developers (and LLMs) love