Skip to content

Quick Start

Installation

bash
npm install @mnemoai/core

Basic 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

PresetProviderModelDimensionsEnv Var
openaiOpenAItext-embedding-3-small1536OPENAI_API_KEY
ollamaOllama (local)bge-m31024none needed
voyageVoyage AIvoyage-3-large1024VOYAGE_API_KEY
jinaJina AIjina-embeddings-v31024JINA_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

Released under the MIT License.