Quickstart — Python
The Python SDK is generated from the same OpenAPI document the TypeScript SDK uses, so the surface is identical and the methods feel native to Python.
Run Mnemosyne (one container) and install the SDK
docker run --rm -d --name mnemo \
-e DATABASE_URL=postgres://mnemo:mnemo@host.docker.internal:5432/mnemo \
-e MNEMO_LLM_PROVIDER=openai \
-e MNEMO_LLM_API_KEY=sk-... \
-p 3000:3000 ghcr.io/lucasmailland/mnemosyne-server:latest
# Mint a workspace key to authenticate the SDK
docker exec mnemo node scripts/create-api-key.cjs --workspace demo
pip install mnemosyne-sdkFirst call
app.py
from mnemo import MnemosyneClient
mnemo = MnemosyneClient(
base_url="http://localhost:3000",
api_key="mns_live_demo",
)
mnemo.facts.create(content="Lucas prefers espresso", tags=["coffee"])
hits = mnemo.recall(query="coffee preferences", top_k=3)
for hit in hits.hits:
print(f"{hit.score:.3f} {hit.statement}")FastAPI integration
main.py
from fastapi import FastAPI, Depends
from mnemo import MnemosyneClient
app = FastAPI()
def get_memory():
return MnemosyneClient(
base_url="http://localhost:3000",
api_key="mns_live_demo",
)
@app.post("/agents/recall")
def agent_recall(query: str, mnemo: MnemosyneClient = Depends(get_memory)):
return mnemo.recall(query=query, top_k=5)LangChain adapter
from mnemosyne.langchain import MnemosyneMemory
memory = MnemosyneMemory(
client=mnemo,
namespace="conversation:user_42",
)
# Drop straight into any chain that consumes a BaseMemoryLlamaIndex adapter
from mnemosyne.llamaindex import MnemosyneRetriever
retriever = MnemosyneRetriever(client=mnemo, top_k=5)
nodes = retriever.retrieve("what does the user prefer?")💡
The LangChain and LlamaIndex adapters are thin wrappers — they call the
same recall endpoint. If they don’t match your needs, drop them and use
MnemosyneClient directly.