Quick Start
Get Recall running in your application in under 5 minutes.
Prerequisites
Before you begin, make sure you have:
- Python 3.8+ or Node.js 16+
- Redis installed locally or a Redis Cloud instance
- A Mem0 API key (get one free)
Installation
bashpip install recall-memory
bashnpm install @recall/client
bashyarn add @recall/client
bashpnpm add @recall/client
Basic Setup
1. Start Redis
If you don't have Redis running locally:
bashdocker run -d -p 6379:6379 redis:alpine
bashbrew services start redis
bashsudo systemctl start redis
2. Set Environment Variables
Create a .env file in your project root:
envREDIS_URL=redis://localhost:6379MEM0_API_KEY=your_mem0_api_key_hereRECALL_ENV=development
3. Initialize the Client
pythonfrom recall import RecallClientfrom dotenv import load_dotenvimport os# Load environment variablesload_dotenv()# Initialize clientclient = RecallClient(redis_url=os.getenv("REDIS_URL"),mem0_api_key=os.getenv("MEM0_API_KEY"),environment=os.getenv("RECALL_ENV", "development"))# Test the connectionhealth = client.health_check()print(f"Recall status: {health['status']}")
typescriptimport { RecallClient } from "@recall/client";import dotenv from "dotenv";// Load environment variablesdotenv.config();// Initialize clientconst client = new RecallClient({redisUrl: process.env.REDIS_URL,mem0ApiKey: process.env.MEM0_API_KEY,environment: process.env.RECALL_ENV || "development",});// Test the connectionconst health = await client.healthCheck();console.log(`Recall status: ${health.status}`);
javascriptconst { RecallClient } = require("@recall/client");require("dotenv").config();// Initialize clientconst client = new RecallClient({redisUrl: process.env.REDIS_URL,mem0ApiKey: process.env.MEM0_API_KEY,environment: process.env.RECALL_ENV || "development",});// Test the connectionclient.healthCheck().then((health) => {console.log(`Recall status: ${health.status}`);});
Your First Memory
Let's create, retrieve, and search memories:
python# Store a memorymemory = client.add(content="User prefers concise responses and technical details",user_id="user_123",priority="high",metadata={"category": "preferences","learned_from": "conversation"})print(f"Memory stored with ID: {memory['id']}")# Search memoriesresults = client.search(query="user communication preferences",user_id="user_123",limit=5)for memory in results:print(f"- {memory['content']} (relevance: {memory['score']})")# Get all memories for a userall_memories = client.get_all(user_id="user_123")print(f"Total memories: {len(all_memories)}")
typescript// Store a memoryconst memory = await client.add({content: "User prefers concise responses and technical details",userId: "user_123",priority: "high",metadata: {category: "preferences",learnedFrom: "conversation",},});console.log(`Memory stored with ID: ${memory.id}`);// Search memoriesconst results = await client.search({query: "user communication preferences",userId: "user_123",limit: 5,});results.forEach((memory) => {console.log(`- ${memory.content} (relevance: ${memory.score})`);});// Get all memories for a userconst allMemories = await client.getAll({ userId: "user_123" });console.log(`Total memories: ${allMemories.length}`);
Common Patterns
Conversation Memory
Store and retrieve conversation context:
python# Store conversation turnclient.add(content=f"User asked about {topic}. Provided detailed explanation.",user_id=user_id,priority="medium",metadata={"type": "conversation","session_id": session_id,"timestamp": datetime.now().isoformat()})# Retrieve recent conversation contextcontext = client.search(query="recent conversations",user_id=user_id,filters={"type": "conversation"},limit=10)
typescript// Store conversation turnawait client.add({content: `User asked about ${topic}. Provided detailed explanation.`,userId: userId,priority: "medium",metadata: {type: "conversation",sessionId: sessionId,timestamp: new Date().toISOString(),},});// Retrieve recent conversation contextconst context = await client.search({query: "recent conversations",userId: userId,filters: { type: "conversation" },limit: 10,});
User Preferences
Track and apply user preferences:
python# Store preferenceclient.add(content="Prefers email notifications over SMS",user_id=user_id,priority="high",metadata={"type": "preference", "category": "notifications"})# Check preferences before actionprefs = client.search(query="notification preferences",user_id=user_id,filters={"type": "preference"})
typescript// Store preferenceawait client.add({content: "Prefers email notifications over SMS",userId: userId,priority: "high",metadata: { type: "preference", category: "notifications" },});// Check preferences before actionconst prefs = await client.search({query: "notification preferences",userId: userId,filters: { type: "preference" },});
Performance Tips
1. Use Priority Levels
Set appropriate priority levels to optimize cache usage:
critical: Always in cache, never evictedhigh: Preferentially cached, rarely evictedmedium: Cached when accessed, normal evictionlow: Minimal caching, first to evict
2. Batch Operations
Use batch methods for better performance:
python# Add multiple memories at oncememories = [{"content": "Fact 1", "user_id": "user_123"},{"content": "Fact 2", "user_id": "user_123"},{"content": "Fact 3", "user_id": "user_123"}]client.add_batch(memories)
typescript// Add multiple memories at onceconst memories = [{ content: "Fact 1", userId: "user_123" },{ content: "Fact 2", userId: "user_123" },{ content: "Fact 3", userId: "user_123" },];await client.addBatch(memories);
3. Use Async Operations
For non-critical memories, use async mode:
python# Fire-and-forget for non-critical memoriesclient.add(content="Background information",user_id="user_123",priority="low",async_mode=True # Don't wait for cloud sync)
typescript// Fire-and-forget for non-critical memoriesawait client.add({content: "Background information",userId: "user_123",priority: "low",asyncMode: true, // Don't wait for cloud sync});
Next Steps
Now that you have Recall running:
- Explore the API Reference for all available methods
- Check out Examples for real-world use cases
- Learn about Advanced Features like custom caching strategies
- Read the Best Practices guide for production deployments
Need Help?
- Join our Discord Community
- Check the Troubleshooting Guide
- View the GitHub Repository
- Contact support@recall.ai