AI Memory for Developers: remember(), recall(), forget() in 3 Lines of Code

Most AI applications are stateless. Every conversation starts from zero. Adding persistent memory changes everything -- your agent remembers users, learns preferences, and builds context over time. Here is how to add it in minutes with the REM API.

The 3 Core Operations

The entire memory API surface reduces to three primitives. remember() stores knowledge. recall() retrieves it by semantic similarity. forget() removes it. Everything else -- namespaces, metadata, the Dream Engine -- builds on top of these three.

Python

Install

pip install remlabs

Usage

from remlabs import REM

rem = REM(api_key="your_api_key")

# Store a memory
rem.remember("User prefers dark mode and compact layouts")

# Retrieve by meaning (not keyword match)
results = rem.recall("What does the user like?")
# Returns: "User prefers dark mode and compact layouts"

# Remove a memory
rem.forget(results[0]["id"])

That is the entire getting-started path. Three methods, zero configuration, persistent across sessions.

TypeScript / Node.js

Install

npm install @remlabs/sdk

Usage

import { REM } from "@remlabs/sdk";

const rem = new REM({ apiKey: "your_api_key" });

// Store
await rem.remember("Customer Acme Corp prefers quarterly billing");

// Recall by semantic query
const memories = await rem.recall("Acme billing preferences");

// Forget
await rem.forget(memories[0].id);

CLI

The CLI works the same way, useful for scripting and quick testing.

# Store
rem remember "Deploy target is us-east-1, staging branch is develop"

# Recall
rem recall "deployment config"

# Forget by ID
rem forget mem_7f3a2b...

Namespaces: Separating Memory Contexts

Namespaces let you isolate memory domains. A customer support agent might have separate namespaces for each customer. A personal assistant might separate "work" from "personal." A multi-tenant SaaS uses one namespace per tenant.

# Python -- namespace per user
rem.remember(
    "Prefers email over Slack for updates",
    namespace="user_alice"
)

# Recall only within that namespace
rem.recall("communication preferences", namespace="user_alice")

Namespaces are free to create, require no configuration, and are fully isolated -- a recall in one namespace will never return memories from another.

Dream Engine Integration

Every memory stored via remember() is automatically eligible for Dream Engine consolidation. The engine runs nightly, processing all memories across your namespaces through 9 stages -- synthesizing clusters, extracting patterns, generating insights, and compressing redundancy.

You can also trigger a dream cycle on demand:

# Run a dream cycle on a specific namespace
response = rem.dream(
    namespace="user_alice",
    strategies=["synthesize", "pattern_extract", "insight_generate"]
)

print(f"Insights generated: {response['insights_generated']}")
print(f"Patterns found: {response['patterns_detected']}")

After consolidation, recall() returns both raw memories and dream-generated insights, weighted by relevance and consolidation depth. Memories that have been through multiple dream cycles surface richer, more connected results.

MCP Setup for Claude Code and Cursor

The Model Context Protocol (MCP) lets AI coding tools access REM memory directly. This means Claude Code or Cursor can remember your codebase preferences, architectural decisions, and project context across sessions.

Claude Code -- .claude/settings.json

{
  "mcpServers": {
    "rem": {
      "command": "npx",
      "args": ["-y", "@remlabs/mcp"],
      "env": {
        "REM_API_KEY": "your_api_key"
      }
    }
  }
}

Cursor -- .cursor/mcp.json

{
  "mcpServers": {
    "rem": {
      "command": "npx",
      "args": ["-y", "@remlabs/mcp"],
      "env": {
        "REM_API_KEY": "your_api_key"
      }
    }
  }
}

Once configured, your AI coding assistant gains persistent memory. It remembers your coding style, project conventions, deployment procedures, and architectural decisions -- no more re-explaining your stack every session.

What the MCP server exposes: remember, recall, and forget as MCP tools, plus dream for on-demand consolidation. The AI assistant calls these automatically when it needs to store or retrieve context.

REST API for Everything Else

If you are not using Python or TypeScript, the REST API works from any language.

# Store a memory
curl -X POST https://remlabs.ai/v1/remember \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "Project uses PostgreSQL 16 with pgvector", "namespace": "project_x"}'

# Recall by semantic query
curl -X POST https://remlabs.ai/v1/recall \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "database setup", "namespace": "project_x"}'

Full API documentation including metadata filters, pagination, and batch operations is available at /docs.

Get your API key in 30 seconds

Free tier includes 1,000 memories and nightly Dream Engine consolidation.

Get Started →