Long-term memory for AI agents with Mem0 or Hindsight
Short answer: run a memory server your agent calls over HTTP. It extracts facts from conversations, stores them as vectors in Postgres with pgvector, and returns the relevant ones for each user. On Railway you can deploy Mem0, which suits a quick REST-based memory layer and has a dashboard, or Hindsight, which adds MCP, banks per user or customer, and recall that combines several search types.
Deploy Mem0 on RailwayWhen you need agent memory
A chat model forgets everything between sessions. Memory servers fix that for chatbots, support agents and coding assistants that should remember preferences and past decisions. Your agent writes messages in, and later searches by user, agent or session to add the results to its prompt.
Compare the two templates
| Mem0 | Hindsight | |
|---|---|---|
| Pinned version | v2.2.1 | 1.0.0 |
| Services | API, dashboard, log pruner (daily cron), Postgres with pgvector | API, background worker, Control Plane, Postgres |
| Interface | REST and SDKs | REST, MCP, Python, TypeScript and Go clients |
| Scoping | user_id, agent_id, run_id |
Memory banks |
| LLM key | Required | Optional, enables extraction and reflect |
| Embeddings | Via your provider | Run on CPU inside the image |
| Licence | Apache-2.0 | MIT |
| Template | Creator | Deployments | Services |
|---|---|---|---|
| LibreChat | LibreChat | 6,762 | 5 |
| Hermes Agent by Nous Research | lovexbytes's Projects | 6,413 | 1 |
| OpenClaw | Techulus | 5,167 | 1 |
| Hermes Agent | Heimdall | 4,092 | 1 |
| Bytebot | Bytebot | 3,440 | 4 |
| OpenClaw - Railway Template | Codetitlan | 2,508 | 1 |
| AnythingLLM | Timothy Carambat's Projects | 1,972 | 1 |
| Hermes | Heimdall | 1,881 | 1 |
Railway marketplace data as of 2026-11-19. Full ranking: Best AI agent templates on Railway.
The table above lists AI agent templates on Railway by deployments. It is for context: the memory servers in this guide are linked from the comparison.
Deploy Mem0, step by step
- Deploy with your key. Paste
OPENAI_API_KEYwhen prompted. The template builds the API and dashboard from the pinned release, creates both databases and runs migrations before start. - Sign in. Open the Dashboard URL with
MEM0_ADMIN_EMAILandMEM0_ADMIN_PASSWORD, then change both under Settings. - Create an API key under API Keys.
- Store a memory. Send
POST /memorieswith anX-API-Keyheader and a body such as{"messages": [{"role": "user", "content": "I prefer Python."}], "user_id": "alex"}. - Recall it. Send
POST /searchwith{"query": "language preference", "filters": {"user_id": "alex"}}. Interactive docs are at/docson the API domain.
For Hindsight, sign in to the Control Plane, copy the tenant API key, store with POST /v1/default/banks/{bank}/memories and recall with .../memories/recall. Both calls use Authorization: Bearer {key}. To use MCP, point your client at https://{api-domain}/mcp/{bank}/ with the same header.
Choosing between them
Pick Mem0 when you want the smallest footprint, a dashboard that shows memories, entities and requests, and you already have an OpenAI-compatible key. Pick Hindsight when you want per-user or per-customer banks, MCP for coding assistants, and local embeddings so that storing and recalling chunks works without any external key. Hindsight uses more RAM because the API and worker each load the models. In both cases keep the memory service on Railway’s private network where possible, and call it from your agent’s backend rather than from a browser, so the API key is never exposed to end users.
What persists
Mem0 keeps memories and entity vectors in Postgres and request history in SQLite on a volume; the pruner deletes request logs older than 30 days by default. Hindsight keeps banks, memories, vectors, entities and operations in Postgres on a volume. Back up Postgres before upgrades. In Hindsight, keep HINDSIGHT_API_EMBEDDINGS_PROVIDER fixed once memories exist, because a different embedding size needs an empty database.
Costs
- Mem0: the README’s TEMPLATE.md shows measured RAM after start of about 217 MB for the API, 97 MB for the dashboard and 71 MB for Postgres. The monthly figures are estimates: about $5 idle and about $14 typical. It fits the Trial plan on RAM, and Hobby is recommended for always-on use.
- Hindsight: the figures are estimates from upstream sizing, not measured, because local measurement was blocked. The API and worker each hold the embedding and reranking models in memory, about 1 GB each at idle. Expect roughly $20 per month idle and $45 to $50 with regular use. Hobby is the minimum plan.
LLM calls are billed by your provider in both cases.
Limits and licence notes
- Mem0: runs as one API replica. The admin e-mail is a placeholder, so change it after first login.
- Hindsight:
/docsand/metricson the public API domain are unauthenticated upstream. The first deploy pulls an image of about 0.86 GB compressed. - Licences: see the FAQ. Both are community templates, not affiliated with Mem0 or Vectorize.
Other options
For the vector store alone, see pgvector for RAG. For an always-on agent to attach memory to, see Telegram and Discord agents. More guides are listed at /guides/.
FAQ
How do I log in and get an API key?
Mem0: open the Mem0 Dashboard URL and sign in with MEM0_ADMIN_EMAIL (default admin@example.com) and MEM0_ADMIN_PASSWORD from the Mem0 API service variables, change both under Settings, then create a key under API Keys or use ADMIN_API_KEY. Hindsight: sign in to the Control Plane with HINDSIGHT_CP_ACCESS_KEY, and use HINDSIGHT_API_TENANT_API_KEY as a bearer token on every API and MCP request.
Do I need an LLM key?
Mem0 requires an OpenAI key, or a key for any OpenAI-compatible endpoint through OPENAI_BASE_URL. Hindsight starts without one: memories are stored as chunks and recall works, but fact extraction, consolidation and reflect need HINDSIGHT_API_LLM_API_KEY, plus HINDSIGHT_API_LLM_PROVIDER if you do not use OpenAI. Provider usage is billed by the provider.
What licences apply?
Mem0 is Apache-2.0, built unmodified from the v2.2.1 release. Hindsight, by Vectorize, is MIT, and its bundled embedding and reranker models are MIT and Apache-2.0 per their model cards. Both templates use Postgres with pgvector. This is not legal advice.
Can I connect it over MCP?
Hindsight serves MCP at /mcp/{bank}/ with the same bearer key. Mem0's official MCP server is a hosted service for the Mem0 Platform, and the self-hosted OpenMemory MCP server was removed upstream, so connect to this Mem0 deployment through its REST API or SDKs.
Can I run more than one replica?
Not for the Mem0 API, which keeps history in SQLite on its volume and runs as one replica. For Hindsight, do not add replicas to the worker, because they would share one worker id. Duplicate the worker service with a different HINDSIGHT_API_WORKER_ID or raise HINDSIGHT_API_WORKER_MAX_SLOTS.