
Deploy Mem0 LangGraph
Long-term memory for LangGraph agents via the Mem0 API
Just deployed
Just deployed
/var/lib/postgresql/data
mem0-dashboard
Just deployed
mem0-api
Just deployed
/app/history
Deploy and Host Mem0 LangGraph (Open-Source AI Agent Memory) on Railway
This template deploys Mem0's OSS API and dashboard on Railway so LangGraph agents get long-term, cross-session memory via plain HTTP calls from graph nodes. You run a retrieve node before the LLM and a store node after, using user_id filters. Built for operators who want durable facts without a managed service.
About Hosting Mem0 LangGraph on Railway (self hosted Mem0 template)
You own every extracted memory: the template stores them in your Postgres 18 with pgvector, and the SQLite history file sits on a persistent volume. Nothing goes to Mem0's cloud. You just create an API key and point your LangGraph nodes at /memories and /search.
Why Deploy Mem0 LangGraph on Railway (Railway Free Trial)
Self-hosting Mem0 on Railway gives you the full open-source memory API for the cost of a few small services, usually $10-20/mo, instead of wiring memory extraction into every graph yourself. You control the Postgres data, API keys, and model endpoints. Try it with Railway's $5 trial and pay only for what you run.
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Mem0 LangGraph on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Railway vs Other Hosting Providers and VPS for Mem0 LangGraph self hosting
Railway gives you the full Mem0 stack connected; a VPS leaves you to assemble it.
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | Deployed Mem0 API, dashboard, proxy, and Postgres+pgvector. | A Droplet where you install Docker, Postgres, pgvector, and Caddy by hand. |
| AWS | Managed Postgres, health checks, and $5 trial credit. | EC2 or EKS plus RDS, VPC, and load balancer setup first. |
| Hetzner | Public domain with automatic TLS and internal service DNS. | Cheap VPS, but you configure TLS, proxy, and backups. |
For Mem0 LangGraph, Railway trades a small markup for not running that list.
Common Use Cases for hosted Mem0 LangGraph
- Cross-session support bots: Retrieve node calls POST /search with user_id before the LLM, store node calls POST /memories after reply to save new durable facts.
- Coding assistants per repo: Save decisions under run_id or agent_id, retrieve them in new threads to skip setup and reduce token spend.
- Personal assistants: Persist dietary restrictions or timezone across sessions, inject them into future system prompts.
- Multi-agent teams: Filter by agent_id so a planner and a coder see only relevant facts, keeping prompts focused.
- Long-running research agents: Accumulate facts over weeks under run_id, retrieve relevant context for each new query.
Dependencies for Mem0 Docker hosted on Railway
Four services: mem0 (Caddy 2.11.7, public 8080), mem0-api (8000, volume /app/history), mem0-dashboard (3000), Postgres 18 with pgvector. LangGraph nodes call the API directly.
Deployment Dependencies for Managed Mem0 Service (AI Memory)
Generated: JWT_SECRET, ADMIN_API_KEY, POSTGRES_PASSWORD. Create a per-app m0sk_ key. Store node after reply: POST /memories with messages plus user_id, agent_id, or run_id. Send X-API-Key, keep ADMIN_API_KEY out. Other Railway services call private 8000; outside, public domain.
Implementation Details for Mem0 (Built from the Mem0 v2.2.1 release)
API waits for Postgres, enables pgvector, creates mem0_app, runs migrations, listens dual-stack. MEM0_TELEMETRY=false, AUTH_DISABLED=false, default models gpt-5-mini and text-embedding-3-small; changing embedder dims needs new collection name. Run one replica.
How does Mem0 compare against other AI memory platforms
Mem0 vs LangMem (LangChain's Memory Library)
- Integration model: Mem0 is a standalone REST API called from LangGraph nodes; LangMem is an in-process library for graph code.
- Memory storage: Mem0 extracts and stores facts in Postgres with pgvector across sessions; LangMem stores memories in LangGraph's long-term store and ships its own extraction tools.
- Where LangMem wins: Fewer moving parts, no extra service if you already run LangGraph.
Mem0 vs Zep (Temporal Knowledge Graph Memory)
- Memory model: Mem0 recalls standalone facts by embedding similarity; Zep builds a temporal knowledge graph of entities and relationships.
- Query style: Mem0 search returns memories relevant to the current message; Zep answers relational history questions.
- Where Zep wins: Richer temporal reasoning, though Zep Community Edition self-hosting is deprecated in favor of Zep Cloud.
Mem0 vs Letta (Stateful Agent Server, formerly MemGPT)
- Scope: Mem0 is only the memory layer attached to LangGraph; Letta is a full agent runtime with memory built in.
- Integration: Mem0 works as simple POST /search and POST /memories calls; Letta requires adopting its agent server.
- Where Letta wins: All-in-one stateful server, but you give up LangGraph's graph control.
Mem0 vs LangGraph Checkpointers (Short-Term Thread State)
- Persistence type: Checkpointers save thread-level state for resume or replay; Mem0 stores distilled facts across threads and sessions.
- Use together: Use checkpointers for graph continuity and Mem0 for long-term user knowledge.
- Where checkpointers win: No extra LLM calls or service, but they can't recall cross-session preferences.
How to use Mem0 LangGraph (the OSS AI memory layer)?
- Create a per-app API key (m0sk_ prefix) in the dashboard and set OPENAI_API_KEY on mem0-api (or via Configuration). Without it, memory calls return provider_not_configured.
- Add a retrieve node before your LLM node: POST /search with the latest user message as query, filters user_id and top_k, header X-API-Key. Inject returned memories into the system prompt.
- After the LLM replies, add a store node: POST /memories with the last user and assistant messages plus user_id (or agent_id/run_id). Run it after responding, or in a background task, to keep writes off the hot path. Each write costs one LLM extraction call.
- Use LangGraph checkpointers for short-term thread state and Mem0 for cross-session facts. Pick user_id for per-user memory, agent_id for per-agent scope, run_id for one-off runs. From another Railway service, call the API privately on port 8000.
How to self host Mem0 on other VPS Services (Mem0 self hosting guide)
Clone the Repository
git clone https://github.com/mem0ai/mem0.git
cd mem0/server
The server folder holds the FastAPI server, the Next.js dashboard, and a Docker Compose file.
Install Dependencies
Install Docker and Docker Compose, the supported path; Compose builds the API and dashboard and runs a pgvector Postgres. Or run pip install mem0ai if you only need the Python library without the server.
Configure Environment Variables
Copy .env.example to .env and set at least:
OPENAI_API_KEY=your-openai-key
POSTGRES_PASSWORD=your-db-password
ADMIN_API_KEY=your-admin-key
JWT_SECRET=a-long-random-string
Set MEM0_TELEMETRY=false and AUTH_DISABLED=false. The API waits for Postgres, enables the vector extension, and runs migrations on boot.
Start the Mem0 Application
docker compose up -d
Open your-domain:3000 for the dashboard, create the first admin account, then call POST /memories and POST /search on the API, which Compose publishes on host port 8888.
Official Pricing of Mem0 (Mem0 pricing)
Self-hosting the open-source Mem0 server is free; you only pay for Railway infrastructure and LLM/embedding API calls.
Mem0 cloud vs self hosted comparison (Pricing, features, costs, and more)
Self-hosting Mem0 on Railway costs infrastructure only; the OSS code is Apache-2.0 and free. The managed Mem0 platform adds graph memory, analytics, and no ops, but you pay per request tier.
Monthly cost of self hosting Mem0 on Railway
Expect roughly $10-20 per month on Railway for the four small services plus Postgres with pgvector at light use. That excludes LLM and embedding API calls, which Mem0 makes on every add and search. Railway's $5 free trial covers initial testing.
System Requirements for Hosting Mem0 on a VPS
The stack runs four containers: Caddy, FastAPI, a Next.js dashboard, and Postgres 18 with pgvector. A modest VPS with 2-4 GB of RAM and a couple of vCPUs handles light workloads. The API holds a SQLite history DB on a volume, and Postgres stores the vector collections.
Frequently Asked Questions (FAQs)
Do I need a Mem0 SDK in LangGraph nodes?
No. Call POST /search and POST /memories with httpx or requests. Send an m0sk_ API key in X-API-Key.
Can I run Mem0 without an OpenAI key?
Yes, the stack boots, but memory endpoints return provider_not_configured until you set OPENAI_API_KEY on mem0-api or pick a provider in the dashboard. Any OpenAI-compatible endpoint works.
How is Mem0 different from LangGraph checkpointers?
Checkpointers persist raw thread state. Mem0 extracts durable facts and stores embeddings, so they work across threads and sessions. Use both.
How do I keep memory writes off the hot path?
After the LLM replies, call POST /memories in the same node but after streaming, or push the write to a background task. Each store call adds one LLM extraction call.
Can other Railway services call Mem0 privately?
Yes. Use the internal hostname on port 8000 from another service in the same project. Keep ADMIN_API_KEY out of agents and use per-app m0sk_ keys.
Does self-hosted Mem0 cost anything?
The OSS stack is free. You pay only for Railway services and any LLM or embedding API calls.
Template Content
