---
title: "Deploy Mem0 vs Letta"
description: "Memory layer API vs a stateful agent framework"
category: "AI/ML"
url: https://railway.com/deploy/deploy-mem0-vs-letta-agent-memory
---

# Deploy Mem0 vs Letta

Memory layer API vs a stateful agent framework

**[Deploy Mem0 vs Letta on Railway](https://railway.com/template/deploy-mem0-vs-letta-agent-memory)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/deploy-mem0-vs-letta-agent-memory/manifest.json

- **Creator:** onepush
- **Category:** AI/ML

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### mem0

- **Image:** caddy:2.11.7-alpine@sha256:d8542f48d34a9cf4e4c11a478865229840e87e4c96ea3f439101f31a5d35f75f
- **Start command:** `sh -c 'printf "%s\n" "$CADDYFILE" > /etc/caddy/Caddyfile && exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile'`
- **Health check:** /healthz
- **Public domain:** Yes

### mem0-api

- **Image:** ghcr.io/onepush-dev/mem0-api:v2.2.1@sha256:b43ca243fffdbb8112992b87eb32da39a2e28de2491198a9f72827fe24f8ff91
- **Health check:** /docs

### mem0-dashboard

- **Image:** ghcr.io/onepush-dev/mem0-dashboard:v2.2.1@sha256:9e654f2351b8177296146aab1ba28aa27159b2f54f012762a57c8d59d0c58e82
- **Health check:** /api/health

## Documentation

# Deploy and Host self hosted Mem0 vs Letta (Open-Source AI Memory) on Railway

This template deploys the Mem0 memory API, dashboard, and pgvector Postgres. Unlike Letta, which owns agent state, Mem0 stays a memory layer: you call POST /memories and /search from your existing agent. Fits LangGraph or custom agents needing per-user memory.

## About Hosting Mem0 vs Letta open-source software on Railway (self hosted Mem0 template)

You own the data because this template runs the open-source Mem0 stack: FastAPI service, Next.js dashboard, Caddy in front, and Postgres with pgvector. Your agents call POST /memories and /search directly, and durable facts stay in your Postgres database, not in a vendor account.

## Why Deploy Mem0 vs Letta, the Letta alternative on Railway (Railway Free Trial)

Mem0 keeps your existing agent framework intact, while Letta wants you to build the agent inside its server. You pay only for compute plus LLM calls here, not for a stateful agent runtime. The Railway $5 trial is enough to test it end to end.

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 vs Letta 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 vs Letta self hosting

The template removes the ops work you would do by hand on a raw VPS.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | One-click deploy, managed pgvector Postgres, $5 trial. | A Droplet where you install and maintain Docker, Postgres, Caddy, SSL. |
| AWS | Automatic orchestration, private network, managed Postgres. | EC2, ECS, RDS, VPC, IAM, load balancer to manage. |
| Hetzner | Managed pgvector Postgres, health checks. | Cheap compute, but you run the full stack yourself. |

Railway costs more than a bare Hetzner box, but you skip VPS babysitting.

## Common Use Cases for hosted Mem0 vs Letta

- **Existing agent, just add memory:** With an existing LangGraph or custom loop, call Mem0's POST /memories and /search without changing your runtime; Letta would force a rewrite.
- **Per-user preferences in a support bot:** Tag memories by user_id so each customer gets their own persistent context, not a shared global blob.
- **Multi-agent sharing one user store:** Workers sharing one user_id memory keep consistent facts about a customer across sales, support, and billing agents.
- **When Letta wins:** If you want the agent itself to edit its own core memory and keep state in context, build inside Letta and skip the separate memory API.
- **Swapping LLM providers:** Point OPENAI_BASE_URL at OpenRouter or LiteLLM without touching your agent; changing embedding dimensions needs a new collection name.

## Dependencies for Mem0 vs Letta Docker hosted on Railway

The Mem0 side runs four services: Caddy on port 8080, mem0-api on port 8000, the dashboard on port 3000, and Postgres with pgvector. The API waits for Postgres, enables pgvector, creates mem0_app, and runs alembic migrations.

### Deployment Dependencies for Managed Mem0 vs Letta Service (AI Agent Memory)

The template generates JWT_SECRET, ADMIN_API_KEY, and POSTGRES_PASSWORD. Defaults: AUTH_DISABLED=false, POSTGRES_COLLECTION_NAME=memories.

### Implementation Details for Mem0 vs Letta (Using Mem0 official docker image)

The postgres volume holds memories in the railway database; mem0_app stores users, API keys, settings, and request logs. Health checks: /healthz on Caddy, /docs on the API, /api/health on the dashboard. Keep one replica; SQLite history lives in /app/history. Dashboard settings override env vars.

## How does Mem0 vs Letta compare against other AI agent memory tools

### Mem0 vs Letta (Letta Alternative)

- **Runtime:** Mem0 is a sidecar API; Letta owns the agent loop.
- **Memory:** Mem0 stores by user_id; Letta lets agents edit core memory.
- **Cost:** each Mem0 write is one LLM call; Letta spends tokens on upkeep.
- **Portability:** Mem0 is framework-agnostic; Letta state is locked unless exported.

### Mem0 vs Zep (Zep Alternative)

- **Memory style:** Zep uses temporal graph; Mem0 uses pgvector, simpler but fewer links.
- **Self-host:** Zep's graph adds moving parts; Mem0 needs only Postgres with pgvector.
- **Wins:** Zep is stronger for entity/time recall; Mem0 wins for quick per-user memory.
- **Licensing:** Graphiti is open source; Zep Cloud is commercial; Mem0 OSS stays free.

### Mem0 vs LangMem (LangMem Alternative)

- **Scope:** LangMem is a LangChain library; Mem0 is a framework-neutral REST API.
- **Integration:** LangMem wins inside LangGraph; Mem0 wins across runtimes and languages.
- **Batteries:** both use LLM extraction, but Mem0 ships API keys, tenancy, and a UI.
- **Deployment:** LangMem leaves storage to you; Mem0 gives a hosted service over HTTP.

### Mem0 vs a plain vector database (Vector Database Alternative)

- **What you get:** pgvector stores embeddings; Mem0 adds extraction and search filters.
- **Control:** a vector DB wins on raw control; Mem0 wins on speed to memory.
- **Cost trade:** a vector DB avoids extraction calls; Mem0 accepts consolidation.
- **Ops burden:** with a vector DB you build pipeline; Mem0 is that pipeline deployed.

## How to use Mem0 vs Letta (the OSS AI memory layer)?

1. Open the Railway domain and create the admin account in the setup wizard; registration closes after the first account.
2. Set OPENAI_API_KEY on mem0-api or pick a provider on the Configuration page.
3. Create an app API key (m0sk_ prefix) under API Keys.
4. Store a memory:
```curl
curl -X POST https://your-domain/memories \
  -H "X-API-Key: m0sk_..." \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"I like dark roast"}],"user_id":"alice"}'
```
5. Retrieve it:
```curl
curl -X POST https://your-domain/search \
  -H "X-API-Key: m0sk_..." \
  -H "Content-Type: application/json" \
  -d '{"query":"coffee preference","user_id":"alice"}'
```
6. Call those two endpoints from your agent before and after each model call.

## How to self host Mem0 vs Letta on other VPS Services (Mem0 self hosting guide)

### Clone the Repository

Clone the upstream repo; it ships the server and dashboard with a Docker Compose file (see docs.mem0.ai/open-source).

`git clone https://github.com/mem0ai/mem0`

### Install Dependencies

Install Docker and the Compose plugin. Compose pulls and starts the API, dashboard, and Postgres with pgvector together.

### Configure Environment Variables

Set OPENAI_API_KEY, JWT_SECRET, and POSTGRES_PASSWORD in the env file the Compose setup reads. Use OPENAI_BASE_URL for an OpenAI-compatible endpoint. Dashboard settings override these for most providers.

### Start the Mem0 vs Letta Application

Run `docker compose up -d`, open the dashboard, create the first admin account, and generate an app API key. Your agent then calls POST /memories and POST /search on the API.

## Official Pricing of Mem0 vs Letta (Mem0 pricing)

Mem0 is Apache-2.0, so self-hosting is free; you pay only infrastructure. Its hosted platform has a free Hobby tier, Starter at 19 USD/mo and Pro at 249 USD/mo. Letta is also Apache-2.0 and free to self-host, with Letta Cloud pricing not quoted here. Self-hosted infrastructure on Railway costs roughly 10 to 20 USD/mo for light use, plus LLM and embedding API calls.

## Mem0 vs Letta cloud vs self hosted comparison (Pricing, features, costs, and more)

Self-hosting Mem0 on Railway is cheap, but your LLM and embedding calls are the real recurring cost. Letta's OSS server is also free software, so the decision is about which memory owner you want, not license fees.

### Monthly cost of self hosting Mem0 vs Letta on Railway

Railway cost: about $10-20/mo for four small services plus Postgres at light use. Mem0's OSS is free; you pay OpenAI or Gemini per extraction and embedding call. The $5 trial covers your first deploy.

### System Requirements for Hosting Mem0 vs Letta on a VPS

The Mem0 stack is lightweight: Caddy, FastAPI, Next.js, Postgres with pgvector. No published minimums; for a single-tenant VPS, 2GB RAM and 1-2 vCPU is a safe starting point. Disk: Postgres for the memories collection plus the SQLite history volume on mem0-api.

## Frequently Asked Questions (FAQs)

### Is Mem0 an agent framework?

No. Mem0 is a memory API you call from your existing agent code. It does not run the agent loop; Letta is the one that owns agent state and execution.

### Can I use Mem0 with Letta?

Yes, but it is usually redundant. You could call Mem0 from a Letta tool, but Letta already has its own core and archival memory. Most teams pick one place to own long-term memory.

### Which costs less per message?

Mem0 adds one LLM extraction call per write plus embedding and retrieval costs. Letta spends model tokens on every agent step, including memory edits in context. At low volume, Mem0 is often cheaper because you only pay for memory, not the whole runtime.

### Which is easier to self-host?

Mem0 is easier. It is a simple API plus Postgres with pgvector. Letta needs its own agent server, Postgres, and you configure agents inside it, which is more moving parts.

### Which supports multiple users?

Both. Mem0 isolates memories by user_id, agent_id, or run_id. Letta isolates per agent, so you create separate agent instances per user or tenant. Mem0's filter approach is more direct for many users sharing one agent.

### Can I switch later?

Partly. You can migrate extracted memories from Mem0 to Letta archival memory or vice versa, but the formats differ. Expect a one-time export and re-ingest job, not a live swap.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/deploy-mem0-vs-letta-agent-memory
