RecallKit SDK
🧠 Plug & Play Memory for Your AI Apps
Add intelligent, persistent memory to any AI application with just one line of code. Works with any AI model - OpenAI, Anthropic, Claude, Gemini, or any other provider!
💡 How it works:
- You: Use any AI model you prefer (OpenAI, Anthropic, etc.)
- RecallKit: Uses Gemini internally to process and extract memories
- Result: Your AI app gets persistent memory without vendor lock-in!
✨ Features
- 🌟 Works with Any AI Model: Use OpenAI, Anthropic, Claude, or any provider you prefer
- 🚀 Ultra-Simple API: Just call
recall(result) after any AI interaction
- 🧠 AI-Powered Memory Management: Automatically extracts and manages memories
- 🔍 Smart Duplicate Detection: Prevents redundant memories with intelligent similarity checking
- 💰 Cost-Effective: Smart chunking for long conversations to minimize API costs
- 🛠️ Vercel AI SDK Integration: Built-in tools for seamless integration
- 🔧 Easy Setup: Simple environment variable configuration
🚀 Quick Start
1. Installation
npm install recallkit-sdk ai
npm install @ai-sdk/openai
npm install @ai-sdk/anthropic
npm install @ai-sdk/google
2. Get Your API Keys
Required:
Optional:
- Your preferred AI provider: OpenAI, Anthropic, etc. (for your main AI model)
3. Basic Setup
import { RecallClient } from "recallkit-sdk";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const recall = new RecallClient({
geminiApiKey: "your_gemini_api_key_here",
redis: {
url: "redis://username:password@host:port",
},
memoryNamespace: "my-app",
});
4. Basic Usage
const result = await generateText({
model: openai("gpt-4o"),
prompt: "I love hiking in Colorado",
});
await recall.recall(result, {
userMessage: "I love hiking in Colorado",
});
5. Advanced Usage with AI Tools
const result = await generateText({
model: openai("gpt-4o"),
messages: [
{ role: "user", content: "I work at Google as a software engineer" },
],
tools: recall.createMemoryTools(),
});
🛠️ Next.js Integration
Perfect for Next.js API routes with any AI model:
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";
import { RecallClient } from "recallkit-sdk";
const recall = new RecallClient({
geminiApiKey: "your_gemini_api_key",
redis: {
host: "your-redis-host.com",
port: 6379,
username: "default",
password: "your_redis_password",
},
memoryNamespace: "chat-app",
});
export async function POST(request: Request) {
const { messages } = await request.json();
const memoryContext = await recall.getMemoryContext(
messages[messages.length - 1].content
);
const result = await streamText({
model: openai("gpt-4o"),
messages: [
{
role: "system",
content: `You are a helpful assistant with memory.${memoryContext}`,
},
...messages,
],
tools: recall.createMemoryTools(),
});
return result.toDataStreamResponse();
}
🧠 How It Works
- Use Any AI Model: OpenAI, Anthropic, Claude, Gemini - your choice!
- Call
recall(result): RecallKit processes the conversation using Gemini internally
- Smart Memory Extraction: AI automatically identifies important information to remember
- Semantic Storage: Memories are stored in Redis with vector embeddings
- Context Retrieval: Future conversations automatically include relevant memories
Why Gemini internally? RecallKit uses Gemini for consistent, cost-effective memory processing while letting you use any model for your main application.
📖 Complete Example
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { RecallClient } from "recallkit-sdk";
const recall = new RecallClient({
geminiApiKey: "your_gemini_api_key",
redis: {
url: "redis://username:password@host:port",
},
memoryNamespace: "my-app",
});
async function chatWithMemory(userMessage: string) {
const memoryContext = await recall.getMemoryContext(userMessage);
const result = await generateText({
model: openai("gpt-4o"),
system: `You are a helpful assistant with memory.${memoryContext}`,
prompt: userMessage,
});
await recall.recall(result, { userMessage });
return result.text;
}
const response = await chatWithMemory("I love hiking in Colorado");
console.log(response);
⚙️ Configuration Options
You can customize RecallKit behavior:
const recall = new RecallClient({
geminiApiKey: "your_gemini_api_key",
redis: {
url: "redis://username:password@host:port",
},
memoryNamespace: "my-app",
embeddingModel: "text-embedding-004",
summaryModel: "gemini-1.5-flash",
debug: true,
memoryOptions: {
maxRelatedMemories: 10,
minConfidenceThreshold: 0.7,
autoDeleteAfterDays: 30,
},
});
🗄️ Redis Setup
Free Options:
1. Upstash (Recommended - Serverless)
const recall = new RecallClient({
geminiApiKey: "your_gemini_api_key",
redis: {
url: "redis://default:your_password@your-host.upstash.io:6379",
},
});
const recall = new RecallClient({
geminiApiKey: "your_gemini_api_key",
redis: {
host: "redis-12345.cloud.redislabs.com",
port: 12345,
username: "default",
password: "your_password",
},
});
3. Local Redis (Development)
const recall = new RecallClient({
geminiApiKey: "your_gemini_api_key",
redis: {
host: "localhost",
port: 6379,
},
});
🎨 Advanced Features
- Smart Duplicate Detection: Prevents redundant memories
- Long Conversation Handling: Cost-effective processing of large chats
- Custom Prompts: Customize memory extraction for your use case
- Memory Tools: Let AI manage its own memories with built-in tools
- Semantic Search: Find relevant memories using vector similarity
🚫 Error Handling
Comprehensive error handling with specific error types:
import {
ConfigurationError,
RedisConnectionError,
MemoryProcessingError,
} from "recallkit-sdk";
try {
await recall.recall(result);
} catch (error) {
if (error instanceof ConfigurationError) {
console.error("Config issue:", error.missingField);
} else if (error instanceof RedisConnectionError) {
console.error("Redis connection failed:", error.message);
} else if (error instanceof MemoryProcessingError) {
console.error("Memory processing failed:", error.memoryId);
}
}
📖 Examples
🏗️ Architecture
Simplified API (Recommended)
RecallClient → AI Tools → Smart Memory Management
↓ ↓ ↓
Memory Search → Duplicate Check → Storage
Advanced API (Complex Use Cases)
RecallKit → MemoryProcessor → MemoryAgent → Redis
↓ ↓ ↓ ↓
Config → Extract Memories → Analyze → Store
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
📄 License
MIT License - see LICENSE file for details.
🆘 Support
Made with ❤️ for the AI developer community
Add memory to your AI apps in minutes, not hours.