Automatic memory for any LLM
Two methods. Batteries included. Permem automatically decides what to store, extracts rich context, and builds a knowledge graph — all behind the scenes.
import Permem from 'permem'
const permem = new Permem('pk_...')
// Before LLM call - inject relevant memories
const { injectionText } = await permem.inject(
userMessage, { userId })
// After LLM response - extract new memories
await permem.extract(messages, { userId })Fully Automatic
Permem decides what to store, when to store it, and handles deduplication. Just call inject & extract.
Rich Context
Every memory includes type, importance, emotions, entities, topics, and timestamps — automatically extracted.
Knowledge Graph
Memories are linked into a graph. Visualize connections per user or across your entire project.
How it works
User sends a message
Call inject() before your LLM call. Permem retrieves relevant memories and formats them for your system prompt.
LLM responds with context
Your LLM now has relevant memories in context. It can reference past conversations, preferences, and facts naturally.
Extract new memories
Call extract() after the response. Permem analyzes the conversation, extracts facts, skips duplicates, and stores new memories.
Need more control? Use memorize() and recall() for manual memory management, or as tools for your AI agents.