Watch Vitamem extract facts from a conversation, deduplicate them, and recall them in the next session — the same lifecycle works across any domain.
import { createVitamem } from 'vitamem';
// 1. Initialize with a provider shortcut
const mem = await createVitamem({
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY,
storage: 'ephemeral',
autoRetrieve: true,
});
// 2. Chat — facts are stored in the thread
const thread = await mem.createThread({ userId: 'user-123' });
await mem.chat({ threadId: thread.id, message: "I prefer dark mode, use TypeScript, and deploy on Vercel." });
// 3. Session rests → extract facts, embed once, deduplicate, save
await mem.triggerDormantTransition(thread.id);
// 4. Next session — relevant memories appear automatically
const newThread = await mem.createThread({ userId: 'user-123' });
const { reply } = await mem.chat({
threadId: newThread.id,
message: "What tools do I use?",
});
// Vitamem auto-retrieves: "Prefers TypeScript", "Deploys on Vercel", ...