Vitamem models conversations as sessions with a lifecycle. When a session rests, it extracts the facts that matter, deduplicates them, and makes them available for every future conversation — automatically.
Five lines of code. Zero memory infrastructure to build. Works with any AI that talks to users across sessions.
Vitamem manages the full memory lifecycle behind the scenes.
chatWithUser().sweepThreads().Every thread moves through four states — mirroring how real conversations actually work. Click a state to learn what happens.
These are facts about the code, not marketing claims.
npm test
and see for yourself.
InvalidTransitionError.
The real cost of memory isn't embedding — it's the tokens you send to the LLM on every chat turn. LLM input tokens cost $2.50–15 / 1M — that's 125–750× more expensive than embedding ($0.02 / 1M).
Health companions, coaching assistants, tutoring systems — anywhere your AI needs persistent, cross-session memory.
Bring your own LLM adapter and storage. Vitamem handles the lifecycle and memory.
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. Start a conversation session const thread = await mem.createThread({ userId: 'user-123' }); const { reply } = 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: reply2 } = await mem.chat({ threadId: newThread.id, message: "What tools do I use?", }); // Vitamem auto-retrieves: "Prefers TypeScript", "Deploys on Vercel", ...
Comprehensive documentation covering everything from getting started to API reference.