Long-term memory for AI agents with Mem0 or Hindsight

By Tracklayer · Updated 2026-11-20

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 Railway

When 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
TemplateCreatorDeploymentsServices
LibreChatLibreChat6,7625
Hermes Agent by Nous Researchlovexbytes's Projects6,4131
OpenClawTechulus5,1671
Hermes AgentHeimdall4,0921
BytebotBytebot3,4404
OpenClaw - Railway TemplateCodetitlan2,5081
AnythingLLMTimothy Carambat's Projects1,9721
HermesHeimdall1,8811

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

  1. Deploy with your key. Paste OPENAI_API_KEY when prompted. The template builds the API and dashboard from the pinned release, creates both databases and runs migrations before start.
  2. Sign in. Open the Dashboard URL with MEM0_ADMIN_EMAIL and MEM0_ADMIN_PASSWORD, then change both under Settings.
  3. Create an API key under API Keys.
  4. Store a memory. Send POST /memories with an X-API-Key header and a body such as {"messages": [{"role": "user", "content": "I prefer Python."}], "user_id": "alex"}.
  5. Recall it. Send POST /search with {"query": "language preference", "filters": {"user_id": "alex"}}. Interactive docs are at /docs on 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

LLM calls are billed by your provider in both cases.

Limits and licence notes

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.