Deploy Mem0
Long-term memory for AI agents that remembers across conversations
Just deployed
/var/lib/postgresql/data
mem0-dashboard
Just deployed
mem0-api
Just deployed
/app/history

Deploy and Host Mem0 on Railway
Mem0 is an open-source memory layer for AI agents. Rather than replaying a whole transcript into every prompt, your application posts conversation turns to Mem0, which uses an LLM to extract durable facts — preferences, decisions, constraints — deduplicates them against what it knows, embeds them, and returns the handful that matter next time. With over 60,000 GitHub stars it is the most widely used project in agent memory, and it ships Python and TypeScript SDKs plus LangChain, CrewAI, AutoGen and n8n integrations.
Self-host Mem0 on Railway and you get the whole first-party stack: mem0-api, the FastAPI REST server that owns extraction, storage and search; mem0-dashboard, the official Next.js admin UI for browsing memories, issuing API keys and watching a request audit log; and a managed Postgres with pgvector serving as both vector store and application database. Both images build from tagged mem0ai/mem0 source, since upstream publishes no current image for either half. Agents call the API with an X-API-Key header; only Postgres stays private.

Getting Started with Mem0 on Railway
Deploying gives two public URLs. Open the dashboard first — it redirects to a five-step setup wizard. Step one creates the single admin account; there are no default credentials, and once it exists POST /auth/register returns 403 Registration is closed, so nobody else can claim the instance. Do this immediately.
Step two reviews model providers: Mem0 needs an LLM to extract facts and an embedding model to store them, so paste your OpenAI key here (or set OPENAI_API_KEY on mem0-api). Anthropic and Gemini are bundled on the same screen. Step three issues your first API key — copy it, it is shown once and stored hashed. Step four optionally generates extraction instructions from your use case, and step five runs a live POST /memories against your deployment, confirming everything works before you write code.
Afterwards, Memories lists what is stored filtered by user ID, Entities shows every user_id, agent_id and run_id with counts, and Requests logs status and latency per call.

About Hosting Mem0
Long-running assistants forget. The usual workarounds — stuffing full history into context, or retrieving raw chunks with plain RAG — get expensive and imprecise as conversations grow. Mem0 decides what is worth remembering and returns only relevant facts at query time. Teams self-host it when conversation data cannot leave their infrastructure, when per-request pricing stops making sense, or when they want memory in the Postgres they already back up.
Key capabilities:
- LLM-driven fact extraction, reconciled against existing memories as add, update or delete
- Semantic search over pgvector scoped by
user_id,agent_idorrun_id, with metadata filters - Per-memory history showing when a fact was added, revised or removed
- Per-user API keys with revocation, JWT dashboard sessions, and a request audit log
- Optional expiry dates on memories, and custom extraction prompts
The architecture is small. mem0-api runs its migrations at boot then serves the REST API on port 8000, with a volume at /app/history holding memory history in SQLite. mem0-dashboard is a Next.js server on port 3000 that reads the API's public origin at container start. Postgres holds two databases: the default one carries the pgvector memories collection, and mem0_app holds users, API keys, configuration and request logs.
Why Deploy Mem0 on Railway
Railway removes the operational work around a three-service stack:
- Managed Postgres with pgvector already available
- Both images build from source on push, with health checks and restarts
- Private networking keeps the database off the public internet
- HTTPS domains, certificates and the volume provisioned for you
- Vertical scaling and metrics without touching infrastructure
Common Use Cases
- Personal assistants that remember dietary preferences, timezone and tone across sessions
- Support agents that recall a plan, past tickets and resolutions before the first reply
- Coding agents that retain project conventions and rejected approaches between runs
- Multi-agent systems where several agents share one store scoped by
agent_id
Dependencies for Mem0
- mem0-api —
github.com/mem0ai/mem0at tagv2.0.19,server/. FastAPI on port 8000. - mem0-dashboard — same tag,
server/dashboard/. Next.js standalone on port 3000. - Postgres —
ghcr.io/railwayapp-templates/postgres-ssl:18, with pgvector. - A model provider — OpenAI by default; Anthropic and Gemini bundled, and
OPENAI_BASE_URLtakes any compatible one.
Environment Variables Reference
| Variable | Service | Purpose |
|---|---|---|
OPENAI_API_KEY | mem0-api | Required. Extraction and embedding credential |
JWT_SECRET | mem0-api | Signs dashboard sessions; changing it logs everyone out |
DASHBOARD_URL | mem0-api | The API's CORS allow-list |
MEM0_DEFAULT_LLM_MODEL | mem0-api | Extraction model, default gpt-5-mini |
NEXT_PUBLIC_API_URL | mem0-dashboard | API origin the browser calls |
Deployment Dependencies
- Source: github.com/mem0ai/mem0 (Apache-2.0)
- Docs: docs.mem0.ai
- Runtime: Python 3.12, Node 20, PostgreSQL 18 with pgvector
Hardware Requirements for Self-Hosting Mem0
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU | 2 vCPU |
| RAM | 1 GB total | 2–4 GB |
| Storage | 5 GB volume + database | 10 GB+ as memories grow |
| Runtime | Python 3.12, Node 20, PostgreSQL 17+ with pgvector | Same |
Mem0 runs no inference itself — extraction and embedding are network calls — so the API is light. Plan storage around request_logs, which is append-only and grows roughly 864,000 rows a day at 10 requests per second; prune it with upstream's scripts/prune_request_logs.py.
Self-Hosting Mem0
Everything is reachable over HTTPS with your API key. This stores a memory then searches it, using curl:
curl -X POST https://your-api.up.railway.app/memories \
-H "X-API-Key: m0sk_your_key" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"I am vegetarian and allergic to peanuts"}],"user_id":"alice"}'
curl -X POST https://your-api.up.railway.app/search \
-H "X-API-Key: m0sk_your_key" \
-H "Content-Type: application/json" \
-d '{"query":"what can I eat?","filters":{"user_id":"alice"}}'
From Python, point the official client at your own deployment instead of the hosted service:
from mem0 import MemoryClient
client = MemoryClient(api_key="m0sk_your_key",
host="https://your-api.up.railway.app")
client.add([{"role": "user", "content": "Deploy to staging first"}],
user_id="alice", agent_id="release-bot")
for m in client.search("deployment process", user_id="alice"):
print(m["memory"])
OpenAPI documentation for every route is served at /docs.
Is Mem0 Free to Self-Host?
The Mem0 open-source project is Apache-2.0 licensed and free to run, with no seat limits, feature gates or license key. The hosted Mem0 Platform is a separate commercial product rising from a free tier through $19 and $249 monthly plans priced by request volume; self-hosting replaces it. Your only costs are Railway compute and storage plus your LLM provider's charges. Dashboard entries marked "PRO" — analytics, webhooks, export — belong to the commercial edition and are inert here.
FAQ
What is Mem0? An open-source memory layer for AI agents. It extracts durable facts from conversations, stores them as embeddings, and retrieves the relevant ones later, so an agent behaves as though it remembers.
What does this Railway template deploy?
Three services: the Mem0 REST API, the official dashboard, and managed Postgres with pgvector. Both application images build from tagged mem0ai/mem0 source, since no current published image exists.
Why does the template include Postgres? Two jobs: with pgvector it is the vector store holding embeddings and metadata, and a second database on the same instance holds accounts, API keys, configuration and the request log.
Do I need an OpenAI API key to run self-hosted Mem0?
Yes, or an equivalent. Mem0 builds its LLM and embedding clients at startup, so the API will not start without a provider credential. Anthropic and Gemini are bundled, and OPENAI_BASE_URL points at any OpenAI-compatible endpoint, including a local model server.
How do I authenticate requests to a self-hosted Mem0 API?
Create a key on the API Keys screen and send it as an X-API-Key header. Keys are stored hashed, shown once, tracked with a last-used timestamp, and revocable.
How does Mem0 compare to Zep or Letta? Mem0 bolts onto an agent you already have. Zep builds a temporal knowledge graph, better when you need to know what was true and when. Letta is a runtime where the agent manages its own memory. Keep the API at one replica either way — history lives in SQLite on a volume.
Template Content
mem0-dashboard
gridalpha/mem0-railwaymem0-api
gridalpha/mem0-railwayOPENAI_API_KEY
Required: extraction and embedding credential
