All Frameworks
Node.js SDK Quickstart
Add persistent memory to any Node.js app in under 5 minutes.
1Install & Configure
Install the SDK from npm and set your API key.
npm install agenticmemoryai
export AGENTICMEMORY_API_KEY="amk_your_key_here"
2Store, Recall & Search
Create a space, store messages, search by relevance, and use key-value context.
const { AgenticMemory } = require('agenticmemoryai');
// Initialize (reads AGENTICMEMORY_API_KEY from env)
const memory = new AgenticMemory();
(async () => {
// Create a memory space
const space = await memory.createSpace('My Agent', 'my-agent');
const spaceId = space.space._id;
// Store messages (short-term memory)
await memory.store(spaceId, { role: 'user', content: 'The project deadline is June 15.' });
await memory.store(spaceId, { role: 'assistant', content: 'Got it, I\'ll track that deadline.' });
// Recall recent messages
const msgs = await memory.recall(spaceId, { limit: 20 });
msgs.messages.forEach(m => console.log(`${m.role}: ${m.content}`));
// Search memory (Pro plan)
const results = await memory.search(spaceId, 'deadline', { limit: 10, scope: 'all' });
console.log('Search hits:', results.results.length);
// Key-value context
await memory.setContext(spaceId, 'user_prefs', { theme: 'dark', lang: 'en' }, { ttl: 3600 });
const prefs = await memory.getContext(spaceId, 'user_prefs');
console.log('Prefs:', prefs);
// Long-term entries
await memory.addEntry(spaceId, {
type: 'summary', title: 'Sprint 4',
content: 'Delivered auth module on time', tags: ['project']
});
const entries = await memory.getEntries(spaceId, { limit: 10, tags: ['project'] });
// Entities (people, concepts)
await memory.addEntity(spaceId, {
name: 'Alice', role: 'engineer', knows: ['Python', 'Redis']
});
const entities = await memory.getEntities(spaceId, { knowsContains: 'Python' });
// Bootstrap: load everything at once for agent context
const ctx = await memory.bootstrap(spaceId, {
entries: 5, messages: 20, semantic: true, query: 'deadline'
});
console.log('Context keys:', Object.keys(ctx));
})();
3Expected Output
user: The project deadline is June 15.
assistant: Got it, I'll track that deadline.
Search hits: 2
Prefs: { theme: 'dark', lang: 'en' }
Context keys: [ 'messages', 'entries', 'context', 'entities', 'shared', 'search' ]
Free tier: 1 space, 1K messages/month. Upgrade to Pro ($24.99/mo) for semantic search, entries, and entities.