Deploy Mem0 CrewAI

Give CrewAI agents long-term memory backed by Mem0

Deploy Mem0 CrewAI

Just deployed

/app/history

Just deployed

/var/lib/postgresql/data

Just deployed

Deploy and Host self hosted Mem0 CrewAI (Persistent Memory for CrewAI Crews) on Railway

This template runs a self-hosted Mem0 REST server on Railway, so CrewAI crews keep per-user memory across runs without the hosted platform key.

About Hosting Mem0 CrewAI open-source software on Railway (self hosted Mem0 memory wired into CrewAI crews via MemoryClient, user_id scoping, and a self-hosted Mem0 REST server template)

Your crew's memories live in a Postgres database and a Mem0 API that you own, not in a vendor's cloud.

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

Zep gives you a temporal knowledge graph, but it comes with a hosted subscription and a data path you don't control.

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

Running a self-hosted Mem0 server for CrewAI means keeping four services online, so hosting matters.

ProviderWhat You Get with RailwayWhat You Get with the Other Provider
DigitalOceanA one-click template with the proxy, API, dashboard, and Postgres with pgvector already wired.Root access and a flat monthly droplet price, but you install Docker and set up Postgres and the proxy yourself.
AWSFour services from one template with generated secrets and no VPC or IAM setup first.Fine-grained networking and scaling, but a longer setup for a small memory server.
HetznerManaged deploys that run in minutes with no server upkeep.Low cost per core, but patching, backups, and pgvector fall on you.

Pick Railway if you want the stack running without babysitting it, or a VPS if you want to own the box.

Common Use Cases for hosted Mem0 CrewAI

  • Returning customer preferences: A support crew recalls that a customer prefers email or is on the annual plan, even when runs happen days apart. Each run searches with filters={"user_id": customer_id}.
  • Per-user research isolation: Scope every client.add and client.search call to the analyst's user_id so one person's history never shows up in another's output.
  • In-house user data: Point the crew at a self-hosted Mem0 server on your Railway project. Memories stay in your Postgres with pgvector, and the crew calls your proxy domain instead of api.mem0.ai.
  • Per-user keys for internal tools: Create an m0sk_ key per app or team and send it as X-API-Key. You can revoke one team's access without touching the others.
  • Retrieval comparison: Run the same task with Mem0 results in the description, then with Crew(memory=True) on CrewAI's built-in LanceDB store, and compare the outputs.

Dependencies for Mem0 CrewAI Docker hosted on Railway

This stack is a four-service Mem0 server, and a CrewAI crew reaches it over HTTP like any other memory backend.

Deployment Dependencies for Managed Mem0 CrewAI Service (AI Memory Layer)

  • mem0: Caddy 2.11.7 proxy on port 8080, the only public service, health at /healthz.
  • mem0-api: FastAPI on port 8000, kept private, volume at /app/history.
  • mem0-dashboard: Next.js on port 3000, private.
  • Postgres 18 with pgvector: holds the memories collection and the users and API keys.
  • OPENAI_API_KEY: set on mem0-api, since memory endpoints return provider_not_configured without it.

Implementation Details for Mem0 CrewAI (Using Mem0 official docker image)

The template fixes MEM0_DEFAULT_LLM_MODEL to gpt-5-mini and MEM0_DEFAULT_EMBEDDER_MODEL to text-embedding-3-small, and generates JWT_SECRET, ADMIN_API_KEY, and POSTGRES_PASSWORD.

How does Mem0 CrewAI compare against other ways to add persistent memory to CrewAI crews

Mem0 CrewAI vs CrewAI built-in memory (Competitor Alternative)

  • Where the built-in wins: Crew(memory=True) needs no extra service or keys beyond your LLM and embedder, and it scopes memory with CrewAI's own hierarchy such as /project/alpha.
  • Scope model: CrewAI scopes by project and agent, while Mem0 scopes by user_id, so each customer's history stays separate across runs.
  • Storage: the built-in store is LanceDB under ./.crewai/memory on the machine running the crew, while Mem0 persists to Postgres you host yourself.
  • Wiring: the Mem0 guide keeps memory=True and memory_config off the Crew entirely and calls MemoryClient add and search by hand.

Mem0 CrewAI vs Zep (Competitor Alternative)

  • Where Zep wins: Zep's temporal knowledge graph tracks how facts change over time, and Graphiti, its open-source engine, is a strong fit if relationships matter more than recall.
  • Hosting: Zep Cloud is commercial, while the Mem0 stack here runs on your own Railway project with the Apache-2.0 server.
  • Retrieval: Mem0 returns relevant facts per user_id, which is simpler to fold into a CrewAI task description.

Mem0 CrewAI vs Letta (Competitor Alternative)

  • Where Letta wins: Letta is an Apache 2.0 stateful agent server, formerly MemGPT, and it manages memory inside its own agent runtime end to end.
  • Architecture: Letta asks you to adopt its agent runtime, while Mem0 slots in beside an existing CrewAI crew without replacing it.
  • Control: with Mem0 you call the REST API yourself and keep the crew logic in plain CrewAI code.

Mem0 CrewAI vs LangMem (Competitor Alternative)

  • Where LangMem wins: LangMem is a LangChain library, so it fits best if your app already runs on LangGraph.
  • Framework fit: this Mem0 stack targets CrewAI crews, while LangMem assumes the LangChain and LangGraph ecosystem.
  • Deployment: LangMem is a library you embed, whereas the Mem0 template gives you a private REST server on Railway that any service can call on port 8000.

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

  1. Deploy the template on Railway and note the public mem0 proxy domain. 2. Set OPENAI_API_KEY on mem0-api, plus OPENAI_BASE_URL for an OpenAI-compatible endpoint. 3. Create a per-user key via POST /api-keys and keep the m0sk_ value. 4. Run pip install crewai crewai-tools mem0ai. 5.
import os
from crewai import Agent, Task, Crew, Process
from mem0 import MemoryClient

os.environ["MEM0_API_KEY"] = "m0sk_your_key_here"
os.environ["OPENAI_API_KEY"] = "sk-your-openai-key"
os.environ["SERPER_API_KEY"] = "your-serper-key"

client = MemoryClient()
user_id = "crew_user_1"

client.add([
    {"role": "user", "content": "I prefer short bullet summaries."},
    {"role": "assistant", "content": "Noted."},
], user_id=user_id)

hits = client.search("summary style", filters={"user_id": user_id})
memories = "\n".join(r["memory"] for r in hits["results"])

researcher = Agent(role="Researcher", goal="Research the topic", backstory="Careful analyst.")
task = Task(
    description=f"Research solar panel trends.\nUser preferences:\n{memories}",
    expected_output="A short bullet summary",
    agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[task], process=Process.sequential)
crew.kickoff()

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

This walks through running the Mem0 REST server on your own VPS, then pointing a CrewAI script at it.

Clone the Repository

Grab the upstream Mem0 repo, which ships the server and dashboard with Docker Compose.

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

Install Dependencies

Install Docker and Docker Compose on the VPS, then install the Python client on your dev machine.

pip install crewai crewai-tools mem0ai

Configure Environment Variables

Set an admin key and an OpenAI key on the server.

export ADMIN_API_KEY=your-long-admin-key-16-chars-or-more
export OPENAI_API_KEY=your-openai-key

Memory endpoints return provider_not_configured until a provider is set, so don't skip the OpenAI key.

Start the Mem0 CrewAI Application

Bring the stack up, then confirm /docs loads on your server's port.

docker compose up -d
curl http://your-domain:8888/docs

Railway handles the proxy, API, dashboard, and Postgres with pgvector for you, so you skip the Compose wiring.

Official Pricing of Mem0 CrewAI (Mem0 pricing)

Mem0 is open source under Apache-2.0, so self-hosting the server and dashboard costs you nothing in licenses.

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

The hosted Mem0 platform uses a MEM0_API_KEY against api.mem0.ai with /v1/ paths, while this template runs the open-source REST server on your own Railway project.

Monthly cost of self hosting Mem0 CrewAI on Railway

Four services at light use usually land around $10-20/mo on Railway.

System Requirements for Hosting Mem0 CrewAI on a VPS

Plan for enough RAM to run FastAPI, Next.js, Caddy, and Postgres with pgvector together.

Frequently Asked Questions (FAQs)

Can I use memory_config with provider mem0 on Crew?

Not on current CrewAI releases.

How does user_id scoping keep users apart?

Every add and search call passes a user_id, and searches filter on it with filters={"user_id": user_id}.

How does self-hosted Mem0 differ from the hosted MEM0_API_KEY?

The hosted platform uses MEM0_API_KEY against api.mem0.ai with /v1/ paths.

Why do memory endpoints return provider_not_configured?

The stack boots healthy without an LLM key, but memory calls fail until you set OPENAI_API_KEY on mem0-api or pick a provider on the dashboard Configuration page.

How is this different from CrewAI's built-in memory?

Built-in memory is enabled with memory=True and stores data in LanceDB under ./.crewai/memory on the ma


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
117
View Template
NEW
Weaviate
Vector database with hybrid search and an API key-protected API

zer0person
1
View Template
Möbius v0.1 Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

bento
1