---
title: "Deploy Mem0 Claude"
description: "Self-hosted agent memory powered by Anthropic Claude"
category: "AI/ML"
url: https://railway.com/deploy/deploy-mem0-with-anthropic-claude
---

# Deploy Mem0 Claude

Self-hosted agent memory powered by Anthropic Claude

**[Deploy Mem0 Claude on Railway](https://railway.com/template/deploy-mem0-with-anthropic-claude)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/deploy-mem0-with-anthropic-claude/manifest.json

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

## Template content

### 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

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

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

## Documentation

# Deploy and Host self hosted Mem0 Claude (Self-Hosted Agent Memory on Anthropic Claude) on Railway

This template runs a self-hosted Mem0 memory server that uses Anthropic Claude for memory extraction, with memories kept in your own Postgres.

## About Hosting Mem0 Claude open-source software on Railway (self hosted Mem0 memory with Claude template)

Your users' memory facts stay in a database you control. Memories, users, API keys, and settings all live in your Postgres instance.

Claude handles extraction. Embeddings still need OpenAI or Gemini, so keep that key too. Railway handles hosting, TLS, and private networking between services.

## Why Deploy Mem0 Claude, the Zep alternative on Railway (Railway Free Trial)

Zep Cloud is commercial, while Mem0 is Apache-2.0, so you can self-host and keep memory rows in your own Postgres.

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 Claude 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 Claude self hosting

Railway handles most of the Mem0 Claude stack for you, while a VPS leaves the setup to you.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | Four services and Postgres 18 with pgvector wired up from one template. | A Droplet or managed database you size and secure yourself. |
| AWS | One template with no IAM roles, VPCs, or security groups to configure. | Full networking control, but you assemble ECS or EC2, RDS, and load balancing first. |
| Hetzner | Managed deploys with health checks and a volume for the SQLite history file. | Low server prices, but you install Docker, set up Postgres, and handle TLS. |

Pick Railway for a quick start with less upkeep, or a VPS if you need full control.

## Common Use Cases for hosted Mem0 Claude

- **Long-term memory for a Claude chatbot:** Point your chat app at the Mem0 API so a returning user's preferences and past decisions come back on their next visit, instead of starting from zero each session.
- **Claude doing the fact extraction:** Set provider anthropic with your ANTHROPIC_API_KEY so Claude reads each conversation and decides what is worth keeping, while an OpenAI or Gemini embedder handles the vectors that power search.
- **Per-user memories for a support agent:** Scope every write and search by user_id so one customer's account history never bleeds into another customer's answers.
- **Replacing Claude Projects memory with your own store:** Move context out of a project's built-in memory and into a database you control, so you can query it, export it, and reuse it from any app.
- **Keeping memory data in your own database:** Memories land in your Railway Postgres with pgvector rather than a vendor's cloud, which matters when your users' data needs to stay under your own retention rules.

## Dependencies for Mem0 Claude Docker hosted on Railway

Mem0 Claude runs as four Railway services, and only the Caddy proxy needs a public domain.

### Deployment Dependencies for Managed Mem0 Claude Service (AI Memory Layer)

- **mem0:** Caddy 2.11.7 proxy on port 8080, health at /healthz. It's the only public service.
- **mem0-api:** FastAPI on port 8000, kept private, with a volume at /app/history for the SQLite history database.
- **mem0-dashboard:** Next.js on port 3000, private, health at /api/health.
- **Postgres 18 with pgvector:** the railway database holds memories, and mem0_app holds users, keys, and settings.
- **Keys:** ANTHROPIC_API_KEY on mem0-api for Claude, plus OPENAI_API_KEY for embeddings.

### Implementation Details for Mem0 Claude (Using Mem0 official docker image)

The stack generates JWT_SECRET, ADMIN_API_KEY, and POSTGRES_PASSWORD. Keep mem0-api to one replica, since it writes SQLite history to its volume.

## How does Mem0 Claude compare against other memory layers for Claude-based agents

Mem0 Claude fits when you want Claude doing memory extraction and your memories kept in your own Postgres. Here is how it compares to the alternatives you'll likely weigh.

### Mem0 Claude vs Claude Projects memory (Claude Projects Alternative)

- **Where Projects wins:** It's built into Claude, so there's nothing to deploy or host.
- **Where Mem0 Claude wins:** Memories live in your database, keyed by user_id, and your app can search and delete them through an API.
- **Tradeoff:** You own the infrastructure and the embedding provider setup, which Projects handles for you.

### Mem0 Claude vs Zep (Zep Alternative)

- **Where Zep wins:** Its temporal knowledge graph tracks how facts change over time, which matters if relationships between facts are central to your app.
- **Where Mem0 Claude wins:** It's a single Docker stack with a dashboard, and Mem0 is Apache-2.0 with free self-hosting apart from Railway and API usage.
- **Tradeoff:** Mem0 v2 dropped the graph store from the library, so you won't get relationship modeling out of the box.

### Mem0 Claude vs Letta (Letta Alternative)

- **Where Letta wins:** It's a full stateful agent server under Apache 2.0, with memory managed inside the agent runtime.
- **Where Mem0 Claude wins:** It's a memory layer you add to agent code you already have, without adopting a new framework.
- **Tradeoff:** If you're starting from scratch and want memory and the agent built together, Letta is the more complete choice.

### Mem0 Claude vs Supermemory (Supermemory Alternative)

- **Where Supermemory wins:** It's a hosted memory layer, so there's no server for you to run or patch.
- **Where Mem0 Claude wins:** You keep the data in your own Postgres and choose the LLM and embedder yourself, including Claude for extraction.
- **Tradeoff:** Hosted convenience is Supermemory's strength; control over where memories live is Mem0 Claude's.

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

1. Open the domain after deploy and create the admin account. The first account becomes admin and registration closes.
2. Open the dashboard Configuration page. Pick Anthropic as the LLM provider, paste your ANTHROPIC_API_KEY, and choose a Claude model.
3. Keep an embedder set. Claude handles extraction, but embeddings still need OpenAI or Gemini, so set OPENAI_API_KEY on mem0-api.
4. Create an API key with the m0sk_ prefix under API Keys, then test the endpoints.

```bash
curl -X POST https://your-mem0-domain/memories \
  -H "X-API-Key: m0sk_yourkey" -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"I prefer short answers."}],"user_id":"alice"}'

curl -X POST https://your-mem0-domain/search \
  -H "X-API-Key: m0sk_yourkey" -H "Content-Type: application/json" \
  -d '{"query":"how should I format replies?","filters":{"user_id":"alice"}}'
```

If search returns the stored preference, extraction and the embedder both work.

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

You can run this stack on any VPS with Docker. The steps assume Linux with Docker and Compose installed, and a domain pointed at the box.

### Clone the Repository

Grab the upstream code, which includes the server and dashboard with Compose files.

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

### Install Dependencies

You only need Docker and Compose on the host.

```bash
docker --version
docker compose version
```

### Configure Environment Variables

Claude handles memory extraction but not embeddings, so set an OpenAI or Gemini key too.

```bash
export ANTHROPIC_API_KEY=your-anthropic-key
export OPENAI_API_KEY=your-openai-key
export JWT_SECRET=$(openssl rand -hex 32)
export ADMIN_API_KEY=$(openssl rand -hex 32)
```

Then choose Anthropic as the LLM on the dashboard Configuration page, since dashboard settings override env vars.

### Start the Mem0 Claude Application

Bring up the stack, then open your-domain to create the admin account.

```bash
docker compose up -d
```

Run only one API replica, since it writes SQLite history to a local volume. Railway handles all of this setup for you, which is why its template is the easier path.

## Official Pricing of Mem0 Claude (Mem0 pricing)

The self-hosted Mem0 Claude server is open source under Apache-2.0, so running it costs you nothing in license fees.

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

Here's how running this template compares to Mem0's hosted platform, with the Claude angle front and center.

### Monthly cost of self hosting Mem0 Claude on Railway

Expect roughly $10-20 per month for the four services plus Postgres at light use.

### System Requirements for Hosting Mem0 Claude on a VPS

Run one replica of mem0-api, since it writes SQLite history to the /app/history volume.

## Frequently Asked Questions (FAQs)

### Can Claude do the embeddings too?

No, not on the documented path.

### Which Claude model should I pick?

Start with claude-sonnet-4-6, which is the model shown in the upstream docs example.

### Should I set variables in Railway or use the dashboard?

Either works, but dashboard settings are stored in Postgres and override env vars.

### Can I change the embedder later?

You can, but changing embedding dimensions requires a new collection name, since POSTGRES_COLLECTION_NAME is fixed at memories.

### What does each memory add cost?

Each add makes an LLM call for extraction plus an embedding call, so cost depends on your Claude and embedding provider rates.

### Does Claude see all of a user's memories?

No. Mem0 returns only the memories relevant to the query for a given user_id, so Claude sees the search results you pass into the prompt rather than the full store.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius v0.1 Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/deploy-mem0-with-anthropic-claude
