Memory API
Persistent memory for AI agents. Store, recall, and manage memories with semantic search, auto-classification, and tiered compaction.
$1.00 / 10,000 memories
// Store a memoryawait stack0.memory.store({content: 'User prefers dark mode and compact layout',agentId: 'agent_abc123',type: 'semantic',tags: ['preferences', 'ui'],metadata: { userId: 'user_123' },})// Recall relevant memoriesconst memories = await stack0.memory.recall({query: 'What are the user UI preferences?',agentId: 'agent_abc123',limit: 5,})
What's included
Vector Search
pgvector-powered semantic recall using OpenAI embeddings. Natural language queries find relevant memories instantly.
Auto-Classification
Memories are auto-classified as preference, fact, event, relationship, instruction, or pattern via Claude.
Knowledge Graph
Entities and relationships are automatically extracted from memories, building a queryable knowledge graph.
Tiered Compaction
Hot, warm, cool, and cold tiers. Clusters of related memories are summarized and promoted automatically.
Collections
Group memories into collections with independent compaction and retention policies.
Confidence Scoring
Each memory carries a confidence score. Filter and rank recall results by confidence.
Built for production
Store Memories
Store text memories with embeddings generated automatically. Batch up to 100 at once.
stack0.memory.store({ content, agentId, type })Semantic Recall
Find relevant memories using natural language. Ranked by vector similarity.
stack0.memory.recall({ query, agentId, limit })Keyword Search
Full-text search across memory content and tags for exact matches.
stack0.memory.search({ query, agentId })Agent Scoping
Scope memories to specific agents. Each agent has its own memory space.
stack0.memory.agents.create({ name })Collections & Compaction
Group memories and run compaction to summarize, deduplicate, and archive.
stack0.memory.collections.compact(collectionId)Webhooks
Get notified when compaction completes or memory thresholds are reached.
webhookUrl: 'https://yourapp.com/webhook'Built for real applications
Customer Support Agents
Remember customer preferences, past issues, and conversation history across sessions.
Personal Assistants
Build assistants that learn user preferences and adapt over time.
Knowledge Management
Store procedural knowledge and best practices for retrieval by AI agents.
Multi-Agent Systems
Share memories across agents with collections and scoped access.
Conversational AI
Maintain long-term context beyond a single conversation window.
Onboarding Flows
Remember what users have already completed and personalize the experience.
Simple, usage-based
FAQ
Frequently asked questions
When you store a memory, we generate a vector embedding. When you recall, your query is also embedded and we find the most similar memories using cosine similarity. This means you can search with natural language rather than exact keywords.
Memories are classified into four types: episodic (events and interactions), semantic (facts and knowledge), procedural (how-to instructions), and identity (core traits). You can set the type manually or let the system auto-classify.
Memories start in the hot tier. As they age without access, they move to warm, then cold, then archived. Compaction summarizes groups of related memories into fewer, denser entries, reducing storage while preserving key information.
Yes. The agentId field is optional. You can store and recall memories at the project level without creating agents. Agents are useful when you need to scope memories to specific AI personas.
We use high-quality text embedding models optimized for semantic similarity. Embeddings are generated and stored automatically -- you never need to manage them directly.
Individual memories can be up to 10,000 characters. For longer content, we recommend splitting into multiple memories or using collections to organize them.