Mem0 v2 AI Memory Layer
Mem0 is an open-source memory layer for AI agents: it extracts facts from conversations, stores them as embeddings in Postgres with pgvector and returns relevant ones per user, agent or session. This template deploys the Mem0 v2.2.1 REST API, its dashboard and a pgvector database.
What you get
- The Mem0 REST API built from the pinned v2.2.1 release, with interactive docs at /docs
- The Mem0 Dashboard (Memories, Entities, Requests and API Keys views)
- Postgres 17 with pgvector 0.8.7, with two databases created and migrated before each deploy
- A daily log-pruner cron job that deletes request logs older than 30 days by default
- A dashboard admin created from generated credentials, so nobody else can claim the setup page
Good for
- Long-term memory for chatbots and support agents that remember user preferences
- Shared memory for multi-agent systems scoped by user_id, agent_id and run_id
- Personalising LLM apps with facts recalled through POST /search
- Auditing what agents store and recall through the dashboard
Cost
The template notes measured memory after start: Mem0 API about 217 MB, Dashboard about 97 MB and Postgres about 71 MB, with the spaCy model adding roughly 100 MB on first write. Embedding and LLM work is billed by your model provider, not Railway.
Services in this template
- Mem0 Log Pruner · from
baranberkay96/mem0-railway - Mem0 Dashboard · from
baranberkay96/mem0-railway - Mem0 API · from
baranberkay96/mem0-railway - Postgres · image
pgvector/pgvector:0.8.7-pg17
Questions people ask
What do I need to provide?
An OpenAI API key (OPENAI_API_KEY), or a key for any OpenAI-compatible endpoint set through OPENAI_BASE_URL. Anthropic or Google keys are optional for switching models in the dashboard's Configuration page.
How do I log in and get an API key?
Open the Dashboard URL and sign in with MEM0_ADMIN_EMAIL (default admin@example.com) and MEM0_ADMIN_PASSWORD from the Mem0 API service Variables tab. Create a key under API Keys, or use ADMIN_API_KEY from the API service.
Does it include an MCP server?
No. Mem0's official MCP server is a hosted service for the Mem0 Platform, and the self-hosted OpenMemory MCP server was removed upstream in 2026. Connect agents through the REST API or the Mem0 SDKs.
Is it persistent, and can it scale out?
Memories are in Postgres on a volume, and memory history is kept in SQLite on the API volume. Because of that SQLite file the API runs as one replica; the dashboard is stateless.
How do I upgrade? What licence applies?
The Mem0 release and its checksum are build arguments in both Dockerfiles; change them together, back up Postgres and the history volume, and redeploy. Migrations run before the new version starts. The NOTICE file lists Mem0 as Apache-2.0.
Full template README
Deploy and Host Mem0 with Railway
Mem0 is an open-source memory layer for AI agents and assistants. It extracts durable facts from conversations, stores them as embeddings in Postgres with pgvector, and returns the relevant ones for each user, agent or session. This template deploys Mem0's self-hosted REST API, its web dashboard and a pgvector database, ready for your agents to call.
About Hosting Mem0
The self-hosted Mem0 server is a FastAPI application with authentication, per-user API keys and a request log, plus a Next.js dashboard. It needs Postgres with the pgvector extension, a second database for users and settings, migrations before start, an LLM and embedding provider, and periodic cleanup of request logs. This community template builds the API and dashboard from the pinned Mem0 v2.2.1 release, creates both databases and runs migrations before each deploy, creates the dashboard admin from generated credentials so no one else can claim the setup page, and adds a daily cron job for log retention. It also installs Mem0's recommended NLP extra, which enables hybrid keyword, semantic and entity search.
Common Use Cases
- Long-term memory for chatbots and support agents that remember user preferences across sessions
- Shared memory for multi-agent systems, scoped by
user_id,agent_idandrun_id - Personalising LLM apps with facts recalled through
POST /search - Auditing what your agents store and recall through the dashboard's Memories, Entities and Requests views
Dependencies for Mem0 Hosting
- An OpenAI API key, or a key for any OpenAI-compatible endpoint set through
OPENAI_BASE_URL(required) - Postgres with pgvector (included)
- Optional: Anthropic or Google keys to switch models in the dashboard's Configuration page
Deployment Dependencies
- Mem0 repository: https://github.com/mem0ai/mem0
- Self-hosted server README (v2.2.1): https://github.com/mem0ai/mem0/tree/v2.2.1/server
- REST API documentation: https://docs.mem0.ai/open-source/features/rest-api
- pgvector: https://github.com/pgvector/pgvector
Implementation Details
| Service | Source | Purpose |
|---|---|---|
| Mem0 API | Dockerfile, upstream server/ at v2.2.1 |
REST API on port 8000, healthcheck /docs, history volume /app/history; pre-deploy creates databases, migrates and bootstraps the admin |
| Mem0 Dashboard | Dockerfile, upstream server/dashboard/ at v2.2.1 |
Web UI on port 3000, healthcheck /api/health |
| Mem0 Log Pruner | same image as the API, cron 30 3 * * * |
Deletes API request logs older than REQUEST_LOG_RETENTION_DAYS (30) |
| Postgres | pgvector/pgvector:0.8.7-pg17 |
Memory and entity vectors (mem0) and app data (mem0_app) |
First login
- Paste your
OPENAI_API_KEYwhen deploying. - Open the Mem0 Dashboard URL and sign in with
MEM0_ADMIN_EMAIL(defaultadmin@example.com) andMEM0_ADMIN_PASSWORDfrom the Mem0 API service's Variables tab. Change both under Settings. - Create an API key under API Keys, or use
ADMIN_API_KEYfrom the API service. - Store a memory:
curl -X POST https://{api-domain}/memories -H "X-API-Key: {key}" -H "Content-Type: application/json" -d '{"messages": [{"role": "user", "content": "I prefer Python."}], "user_id": "alex"}'. Recall it withPOST /searchand{"query": "language preference", "filters": {"user_id": "alex"}}. Interactive docs are athttps://{api-domain}/docs.
MCP: Mem0's official MCP server is a hosted service for the Mem0 Platform; the self-hosted OpenMemory MCP server was removed upstream in 2026. Connect agents to this deployment through the REST API or the Mem0 SDKs.
Scaling: the API keeps memory history in SQLite on its volume, so it runs as one replica; give it more RAM or CPU if extraction traffic grows. The dashboard is stateless. Postgres can be resized vertically.
Pinning and upgrades: the Mem0 release and its source checksum are build arguments in both Dockerfiles. Change them together, back up the Postgres and history volumes, and redeploy; migrations run automatically before the new version starts.
Why Deploy Mem0 on Railway?
Railway runs the API, dashboard, database and cron job together with private networking, persistent volumes and HTTPS, so your agents get a memory service you own within minutes. You pay for the small amount of RAM and CPU it uses, and your memories stay in your own database.
Guides for this template
View Mem0 v2 AI Memory Layer on railway.com
Similar templates
| Template | Category | DeploymentsDeploys |
|---|---|---|
| 9Router Self-hosted AI router for Claude, Gemini, Cursor & OpenAI tools. | AI/ML | 9,734 |
| flowise-railway Flowise - low-code LLM apps builder | AI/ML | 8,512 |
| LibreChat Open-source ChatGPT clone: multi-model, agents, search, multi-user auth | AI/ML | 6,762 |
| Hermes Agent by Nous Research Template for Hermes Agent by Nous Research | AI/ML | 6,413 |
| OpenClaw [Homebrew support] The AI that actually does things | AI/ML | 5,167 |
| Hermes Agent Self Host Hermes Agent. Autonomous AI agent w/ self-improving, tools & more | AI/ML | 4,092 |