What happens under the hood
01 · Active
Chat freely Messages are stored in the thread. No embedding calls yet.
02 · End session
LLM extracts facts One LLM call pulls structured facts from the full conversation.
03 · Dormant
Embed only the facts ~6 facts = ~6 embedding calls. Not 1 per message.
04 · New session
Retrieve and inject Cosine search surfaces relevant memories. AI references them naturally.
Developer Assistant Active
thread_sess1_demo
Thread Info
User alex@example.com
State active
Messages 0
Memories 0
Embed calls 0
Extraction Pipeline
1
LLM extraction
1 API call · full conversation
2
Embedding facts
6 calls · extracted facts only
3
Deduplication
cosine similarity ≥ 0.92
4
Saved to storage
6 memories stored
Memories 0
🧠
No memories yet.
End the session to extract them.

The code behind this demo

View full examples →
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", ...
Note: Vitamem is a developer library for AI memory management, not a medical device. If you build health-related applications, you are responsible for compliance (HIPAA, GDPR, etc.) and safety disclosures. Full disclaimer →