Complete reference for all AI Memory methods, classes, and utilities.
Main class for managing persistent memory
| Method | Description |
|---|---|
remember(content, metadata) | Add a memory with content and optional metadata |
rememberFact(content, metadata) | Add a factual memory with fact type |
rememberPreference(content, metadata) | Add a user preference memory |
rememberConversation(content, role, metadata) | Add a conversation message (user/assistant) |
recall(query, options) | Search memories by semantic similarity with filters |
getContext(query) | Build optimized context for LLM with token management |
getMemory(id) | Retrieve a specific memory by its ID |
updateMemory(id, updates) | Update content or metadata of an existing memory |
forget(id) | Delete a memory permanently |
getMemoriesByUser(userId) | Get all memories for a specific user |
getMemoriesByType(type) | Get memories filtered by type (fact, preference, etc.) |
getStats() | Get memory statistics and usage metrics |
exportData() | Export all memories as JSON for backup |
importData(memories) | Import memories from JSON |
Manage user plans and rate limiting for monetization
import { PlanManager, PLANS } from 'ai-memory';
const planManager = new PlanManager();
// Set user plan
planManager.setUserPlan('user-123', 'pro');
// Check rate limit
const rateResult = await planManager.checkRateLimit('user-123');
if (!rateResult.allowed) {
console.log('Rate limit exceeded:', rateResult.retryAfter);
}
// Check usage limit
const usageResult = await planManager.checkUsageLimit('user-123', 'api_calls');
console.log(`Remaining: ${usageResult.remaining}/${usageResult.limit}`);
// Get plan details
const plan = planManager.getPlan('pro');
console.log(`Max memories: ${plan.limits.maxMemories}`);All available configuration options for createAIMemory()
| Option | Type | Default | Description |
|---|---|---|---|
maxMemories | number | 10000 | Maximum memories to store |
embeddingDimension | number | 1536 | Embedding vector dimension |
maxTokens | number | 4000 | Max tokens for context |
relevanceThreshold | number | 0.7 | Min similarity score (0-1) |
defaultImportance | number | 0.5 | Default importance (0-1) |
autoCleanup | object | - | Auto cleanup configuration |
storage | object | memory | Storage backend config |
Plan limits and features
| Feature | Free | Pro | Enterprise |
|---|---|---|---|
| Max Memories | 1,000 | 50,000 | Unlimited |
| Searches/Day | 100 | 10,000 | Unlimited |
| Persistence | In-Memory | Redis | PostgreSQL |
| Support | Community | Priority 24/7 | |
| Analytics | - | ✓ | ✓ |
| Custom Integrations | - | - | ✓ |
| Price | $0/mo | $29/mo | $99/mo |