+
REM Labs · LangChain

Memory that persists across every LangChain chain

LangChain's built-in memory lives in RAM — it vanishes on restart. REM is a drop-in BaseMemory backend that saves every turn to a persistent substrate with semantic search, entity graph, and overnight Dream Engine consolidation.

Free tier · No credit card · Works with LangChain Python and JS

Why LangChain + REM

Three things LangChain's default memory classes cannot do.

Continuity across sessions

Chains, AgentExecutors, LangGraph nodes all read the same persistent store. Restarts, cold starts, and kernel deaths don't wipe state.

9 Dream Engine strategies

While your agent sleeps, REM consolidates: summarize, link, de-duplicate, score salience, detect contradictions. Recall gets better overnight, automatically.

Cross-tool portability

The same namespace a LangChain agent writes to is queryable from CrewAI, AutoGen, Cursor, or raw curl. One memory layer, every framework.

Install in 60 seconds

No SDK dependency. The REM Labs REST API is the install — any HTTP client works.

The Python and JS SDKs are in private beta. The curl/requests pattern below is the production path today. Request SDK access in Discord to get early drops.

1

Get your API key

Sign up at remlabs.ai/console. Copy the sk-rem-... key and export it.

export REM_API_KEY="sk-rem-..."
2

Verify the API with a curl

Every REM endpoint speaks JSON over HTTPS. Two calls prove the round-trip.

# Write a memory curl -X POST https://remlabs.ai/v1/memory-set \ -H "Authorization: Bearer $REM_API_KEY" \ -H "Content-Type: application/json" \ -d '{"namespace":"langchain-demo","key":"user_pref","value":"Prefers Python 3.12 and functional style"}' # Semantic search it back curl -X POST https://remlabs.ai/v1/memory-search-semantic \ -H "Authorization: Bearer $REM_API_KEY" \ -H "Content-Type: application/json" \ -d '{"namespace":"langchain-demo","query":"what language do I prefer","limit":5}'
3

Wrap it as a LangChain BaseMemory

Subclass BaseMemory, forward load_memory_variables and save_context to the REST endpoints. 35 lines, zero magic.

Common patterns

Copy-paste these three shapes to cover 95% of LangChain memory use cases.

1. BaseMemory wrapper for ConversationChain

Python

Drop-in replacement for ConversationBufferMemory. Works with any ConversationChain or AgentExecutor.

import os, requests from langchain.memory.chat_memory import BaseChatMemory from langchain_core.messages import HumanMessage, AIMessage REM = "https://remlabs.ai/v1" H = {"Authorization": f"Bearer {os.environ['REM_API_KEY']}", "Content-Type": "application/json"} class RemMemory(BaseChatMemory): namespace: str = "default" memory_key: str = "history" @property def memory_variables(self): return [self.memory_key] def load_memory_variables(self, inputs): q = inputs.get("input", "") r = requests.post(f"{REM}/memory-search-semantic", headers=H, json={"namespace": self.namespace, "query": q, "limit": 8}).json() ctx = "\n".join(f"- {m['value']}" for m in r.get("results", [])) return {self.memory_key: ctx} def save_context(self, inputs, outputs): requests.post(f"{REM}/memory-set", headers=H, json={ "namespace": self.namespace, "key": f"turn_{inputs.get('input','')[:40]}", "value": f"User: {inputs.get('input')}\nAI: {outputs.get('response','')}", }) def clear(self): pass # Use it from langchain.chains import ConversationChain from langchain_openai import ChatOpenAI chain = ConversationChain(llm=ChatOpenAI(model="gpt-4o"), memory=RemMemory(namespace="alice")) chain.predict(input="My favorite editor is Cursor and I ship on Vercel.") # ...restart the process, even deploy to a new server... chain.predict(input="Where do I deploy?") # answers "Vercel" — from REM, not RAM

2. Tool-style semantic recall for AgentExecutor

Python

Expose REM as a first-class LangChain Tool so the agent decides when to remember.

from langchain.agents import Tool, initialize_agent, AgentType def recall(query: str) -> str: r = requests.post(f"{REM}/memory-search-semantic", headers=H, json={"namespace": "alice", "query": query, "limit": 5}).json() return "\n".join(f"- {m['value']}" for m in r.get("results", [])) or "(nothing found)" def remember(fact: str) -> str: requests.post(f"{REM}/memory-set", headers=H, json={"namespace": "alice", "key": fact[:40], "value": fact}) return "ok" tools = [ Tool(name="recall", func=recall, description="Search persistent memory for facts about the user."), Tool(name="remember", func=remember, description="Store an important fact for future sessions."), ] agent = initialize_agent(tools, ChatOpenAI(model="gpt-4o"), agent=AgentType.OPENAI_FUNCTIONS, verbose=True) agent.run("Remember that I use Bun, not Node. Then tell me which runtime I use.")

3. LangChain.js / LangGraph.js

TypeScript

Same REST calls. Use fetch, undici, or any HTTP client.

const REM = "https://remlabs.ai/v1"; const H = { "Authorization": `Bearer ${process.env.REM_API_KEY}`, "Content-Type": "application/json" }; async function recall(namespace: string, query: string) { const r = await fetch(`${REM}/memory-search-semantic`, { method: "POST", headers: H, body: JSON.stringify({ namespace, query, limit: 8 }), }); const { results = [] } = await r.json(); return results.map((m: any) => `- ${m.value}`).join("\n"); } async function remember(namespace: string, key: string, value: string) { await fetch(`${REM}/memory-set`, { method: "POST", headers: H, body: JSON.stringify({ namespace, key, value }), }); } // Inject `recall(...)` output into your LangChain.js prompt before calling the LLM. // Call `remember(...)` after each turn. That's the full integration.

What you get

Everything LangChain's in-memory classes leave on the table.

Cross-session memory

One namespace per user, project, or crew. Survives restarts, deploys, zero-scale cold starts.

Semantic search under 180ms

Vector + FTS5 fusion on every write. 94.6% on LongMemEval, median latency faster than a vector-only stack.

Overnight consolidation

Dream Engine runs 9 strategies while your agent idles — summarize, link, dedupe, reweight salience. Recall improves without you shipping code.

Shared across all your agents

The same store LangChain writes to is what CrewAI, AutoGen, Cursor, and your custom Zapier flows read from. One brain, many mouths.

Give your LangChain agents a real memory

Free tier, no credit card. Ship an agent that remembers across sessions in under a minute.

Get API key Read full docs