Quick Start
Installation
bash
npm install @mnemoai/coreBasic Usage
typescript
import { createMnemo } from '@mnemoai/core';
// Auto-detect: uses OPENAI_API_KEY from env
const mnemo = await createMnemo({ dbPath: './my-memory-db' });
// Or use a preset (no config needed):
// const mnemo = await createMnemo({ preset: 'openai', dbPath: './my-memory-db' });
// const mnemo = await createMnemo({ preset: 'ollama', dbPath: './my-memory-db' });
// Store memories
await mnemo.store({ text: 'User prefers dark mode', category: 'preference' });
await mnemo.store({ text: 'User is a backend engineer', category: 'fact' });
// Recall — automatically applies decay, dedup, and ranking
const results = await mnemo.recall('What does the user do?');
for (const r of results) {
console.log(`[${r.score.toFixed(2)}] ${r.text}`);
}
// Stats
const { totalEntries } = await mnemo.stats();
console.log(`Total memories: ${totalEntries}`);
// Cleanup
await mnemo.close();Using Ollama ($0, fully local)
No API key needed — see the Local Setup guide.
typescript
const mnemo = await createMnemo({ preset: 'ollama', dbPath: './my-memory-db' });Or with full config:
typescript
const mnemo = await createMnemo({
embedding: {
provider: 'openai-compatible',
apiKey: 'ollama',
baseURL: 'http://localhost:11434/v1',
model: 'bge-m3',
dimensions: 1024,
},
dbPath: './my-memory-db',
});Available Presets
| Preset | Provider | Model | Dimensions | Env Var |
|---|---|---|---|---|
openai | OpenAI | text-embedding-3-small | 1536 | OPENAI_API_KEY |
ollama | Ollama (local) | bge-m3 | 1024 | none needed |
voyage | Voyage AI | voyage-3-large | 1024 | VOYAGE_API_KEY |
jina | Jina AI | jina-embeddings-v3 | 1024 | JINA_API_KEY |
Using a Different Backend
typescript
const mnemo = await createMnemo({
preset: 'openai',
dbPath: './my-memory-db',
storageBackend: 'qdrant',
storageConfig: { url: 'http://localhost:6333' },
});See Storage Backends for all options.
Next Steps
- Local Setup ($0) — Run everything locally with Ollama
- Configuration — All config options explained
- API Reference — Full API documentation
- Storage Backends — LanceDB, Qdrant, Chroma, PGVector