SDKsPython SDK

Python SDK

The package is named mnemo-ai-sdk and is imported as mnemo. It is not published to PyPI. Install it from the repository:

pip install "git+https://github.com/lucasmailland/mnemosyne.git#subdirectory=packages/sdk-python"
⚠️

mnemosyne-sdk on PyPI belongs to an unrelated project. Do not install it.

Construct

from mnemo import MnemosyneClient
 
client = MnemosyneClient(
    url="http://localhost:3939",
    api_key="mns_live_...",
    timeout=10.0,     # seconds, default 30.0
    max_retries=3,    # extra attempts on 429 and 5xx, default 3
)

url and api_key are required. The other parameters are timeout, max_retries, user_agent_suffix and workspace_id. The client is also a context manager, which closes the connection pool on exit:

with MnemosyneClient(url="http://localhost:3939", api_key="mns_live_...") as client:
    client.health()

Core methods

Every method returns a plain dict with the server’s JSON, or None for a 204 response.

# Remember
fact = client.create_fact(
    "Acme prefers communication in Spanish.",
    tags=["client:acme"],
)
 
# Recall
result = client.recall(query="what language should we use with Acme?", top_k=5)
for hit in result["hits"]:
    print(f'{hit["score"]:.2f}  {hit["content"]}')
 
# Pin and unpin
client.pin_fact(fact["id"])
client.unpin_fact(fact["id"])
 
# Forget: a soft delete, the fact is closed and not erased
client.forget_fact(fact["id"])
 
# Timeline
timeline = client.timeline(limit=20, since="2026-06-01T00:00:00Z")
for event in timeline["events"]:
    print(event["at"], event["kind"])

create_fact posts to POST /remember and sends the statement, attribution, tags and session_id. It does not expose kind, scope, scopeRef or topicKey. recall takes query, vector, top_k, as_of, vector_weight and session_id. as_of (ISO 8601, not in the future) ranks what memory held at that instant.

Async

AsyncMnemosyneClient has the same constructor and the same method names:

import asyncio
from mnemo import AsyncMnemosyneClient
 
async def main() -> None:
    async with AsyncMnemosyneClient(
        url="http://localhost:3939",
        api_key="mns_live_...",
    ) as client:
        result = await client.recall(query="firmware release cadence", top_k=3)
        print(result["hits"])
 
asyncio.run(main())

Sessions

session = client.create_session(agentId="support-bot", label="ticket 4812")
 
client.add_turn(session["id"], "user", "The robot stops at aisle 4.")
client.add_turn(session["id"], "assistant", "Firmware 2.8 fixes that.")
 
result = client.collapse_session(session["id"])

create_session and collapse_session send their keyword arguments as the JSON body unchanged, so use the server’s field names (agentId, not agent_id).

Pagination

There are no iterators. list_facts returns one page and a nextCursor:

cursor = None
while True:
    page = client.list_facts(limit=100, cursor=cursor)
    for fact in page["items"]:
        print(fact["id"], fact["statement"])
    cursor = page.get("nextCursor")
    if not cursor:
        break

Errors

from mnemo import MnemosyneAPIError, MnemosyneNetworkError, MnemosyneTimeoutError
 
try:
    client.recall(query="firmware release cadence")
except MnemosyneAPIError as err:
    print(err.status, err.code, err.request_id)
except MnemosyneTimeoutError:
    print("timed out")
except MnemosyneNetworkError as err:
    print(f"could not reach the server: {err}")
ClassWhen
MnemosyneErrorBase class of the others
MnemosyneAPIErrorNon-2xx response. Fields: status, message, code, request_id, body, details, retryable, retry_after_seconds
MnemosyneNetworkErrorTransport failure
MnemosyneTimeoutErrorTimeout. A subclass of MnemosyneNetworkError
MnemosyneResponseErrorA successful response whose body is not valid JSON

Retries and idempotency

The client retries 429, 500, 502, 503 and 504 with exponential backoff and jitter starting at 200 ms. Timeouts are not retried. Reads are replayed automatically. A write is replayed only when it carries an idempotency key:

import uuid
 
key = str(uuid.uuid4())
client.create_fact(
    "Larkspur Robotics ships firmware every two weeks.",
    idempotency_key=key,
)

What is not in the package

  • No command-line tool. The mnemo CLI is the npm package @mnemo-ai/cli.
  • No LangChain or LlamaIndex adapters.
  • No response models. Responses are plain dicts.

Python 3.9 or later. The only dependency is httpx 0.27 or later.