Get started
Build on the embedded engine
A complete agent with the engine in your process, in Python, Node and Rust.
The engine runs in your process. Data lives on local disk. You own the LLM key and the maintenance schedule. For automatic fact extraction, point it at an LLM with MENTEDB_LLM_PROVIDER and MENTEDB_LLM_API_KEY; without them you still get storage and recall.
Python (pip)
pip install mentedb
# for automatic fact extraction, point it at an LLM:
export MENTEDB_LLM_PROVIDER=anthropic # openai | anthropic | ollama
export MENTEDB_LLM_API_KEY=sk-ant-...from mentedb import MenteDB
db = MenteDB("./agent-memory")
# Turn 0: tell it something.
db.process_turn(
user_message="I switched from Postgres to SQLite for side projects",
assistant_response="Noted.",
turn_id=0,
)
# Turn 1: it remembers.
result = db.process_turn(
user_message="what database am I using for side projects?",
turn_id=1,
)
for memory in result.context:
print(memory.content)
# result.facts_extracted -> facts learned this turn (needs an LLM)
# result.contradiction_count -> conflicts with existing beliefs
db.close()Agent loop:
history = []
for turn_id, user_message in enumerate(conversation):
prompt = build_prompt(history, user_message)
reply = call_your_llm(prompt)
result = db.process_turn(user_message, reply, turn_id)
history = result.contextNode (npm)
Same embedded engine, native Node binding. processTurn is positional and synchronous, it returns the result object directly, no object argument and no await.
npm install mentedb
# for automatic fact extraction, point it at an LLM:
export MENTEDB_LLM_PROVIDER=anthropic # openai | anthropic | ollama
export MENTEDB_LLM_API_KEY=sk-ant-...const { MenteDB } = require("mentedb");
const db = new MenteDB("./agent-memory");
// Turn 0: tell it something.
db.processTurn("I switched from Postgres to SQLite for side projects", "Noted.", 0);
// Turn 1: it remembers.
const result = db.processTurn("what database am I using for side projects?", undefined, 1);
for (const memory of result.context) console.log(memory.content);
// result.factsExtracted -> facts learned this turn (needs an LLM)
// result.contradictionCount -> conflicts with existing beliefs
db.close();processTurn(userMessage, assistantResponse?, turnId?, projectContext?, agentId?, sessionId?, userId?) is synchronous and returns the result object directly (userId and agentId are orthogonal owner-scoping axes for per-user isolation). Agent loop:
let history = [];
for (let turnId = 0; turnId < conversation.length; turnId++) {
const userMessage = conversation[turnId];
const prompt = buildPrompt(history, userMessage);
const reply = await callYourLlm(prompt);
const result = db.processTurn(userMessage, reply, turnId);
history = result.context;
}Rust (cargo)
Embed the engine directly, no server, no network. DeltaTracker comes from mentedb_context. session_id, project_context, and agent_id are optional on ProcessTurnInput (the Rust struct literal sets every field, so pass None when unused).
cargo add mentedbuse mentedb::{MenteDb, process_turn::ProcessTurnInput};
use mentedb::context::DeltaTracker;
let db = MenteDb::open(std::path::Path::new("./agent-memory"))?;
let mut delta = DeltaTracker::default();
let result = db.process_turn(&ProcessTurnInput {
user_message: "I switched from Postgres to SQLite for side projects".into(),
assistant_response: Some("Noted.".into()),
turn_id: 0,
project_context: None,
agent_id: None,
user_id: None,
session_id: None,
}, &mut delta)?;
for memory in &result.context {
println!("{}", memory.memory.content);
}If your language is not listed, run the server and call its REST API. See Self-hosted for the server, LLM config, embeddings, and the overnight maintenance it runs to keep memory healthy.