Skip to main content

MemoryOps AI — Python SDK (1.0.0)

A small, typed Python client for the MemoryOps AI API. It makes the governed memory lifecycle — capture, retrieve, govern, forget, audit — a few method calls, while the server stays the source of truth for tenant isolation, policy-before-storage, the deletion guarantee, legal hold, consent, and audit.

The SDK is a thin, faithful client over the HTTP API. It adds no governance of its own — it just makes the governed API easy to call from assistants, agents, and RAG apps.

1. Install the SDK

pip install memoryops-sdk

Only dependency: httpx. That's all you need to call a MemoryOps API — you do not need to clone the repo.

2. Connect to a MemoryOps API

Point the client at any running MemoryOps API and scope it to a tenant/user:

from memoryops import MemoryOpsClient

with MemoryOpsClient("https://your-memoryops-host", "tenant_demo", "user_demo") as mo:
    # Capture (governed write)
    mo.chat("Remember I prefer metric units and dark mode.")

    # Retrieve (later turns get the governed memory context)
    answer = mo.chat("What units should I use?")
    print(answer.assistant_message)
    print([u.content for u in answer.used_memories])

    # Inspect
    for m in mo.list_memories():
        print(m.memory_type, m.content, m.status)

The tenant_id and user_id you pass to the constructor are injected on every scope-bearing call — your code never hand-builds request bodies or leaks another user's scope. (Global endpoints — loops, loop_trace, health, workers_health — carry no per-tenant scope by design.)

Authentication

With the default MEMORYOPS_AUTH_MODE=none, the API trusts the caller-supplied scope and no credentials are needed. When it runs with an auth adapter (auth-adapters.md), attach credentials on construction — they are sent on every request:

# Bearer JWT (MEMORYOPS_AUTH_MODE=jwt)
MemoryOpsClient(base_url, tenant_id, user_id, token=my_jwt)

# Trusted upstream header, an API key, or any custom default headers
MemoryOpsClient(base_url, tenant_id, user_id,
                headers={"X-MemoryOps-User": "user_demo"})

# Dynamic / refreshing credentials
MemoryOpsClient(base_url, tenant_id, user_id, auth=my_httpx_auth)

The server authorizes independently: credentials must resolve to the same tenant_id/user_id scope, or the API returns 401/403.

Copy-paste snippets

Govern a memory (legal hold blocks deletion):

from memoryops import LegalHoldError

mo.set_legal_hold(memory_id, on=True, reason="litigation")
try:
    mo.delete_memory(memory_id)
except LegalHoldError:
    ...  # blocked until the hold is released
mo.set_legal_hold(memory_id, on=False)
mo.delete_memory(memory_id)

Honor consent withdrawal (retention worker will expire it):

mo.set_consent(memory_id, status="withdrawn")

Preview retention decisions (read-only, deletes nothing):

for d in mo.retention_decisions(policy="strict"):
    print(d.memory_id, d.outcome, d.eligible_for_deletion, d.blocked_by)

Recall without storing (read-only turn):

hits = mo.chat("What do you know about me?", temporary_chat=True).used_memories

Read the audit trail (governance evidence):

for e in mo.audit(limit=20):
    print(e.action, e.reason)

API surface

Area Methods
Construct MemoryOpsClient(base_url, tenant_id, user_id, *, token=, headers=, auth=, timeout=, http_client=)
Chat chat(message, temporary_chat=, conversation_id=, audience=)
Memories list_memories, get_memory, update_memory, delete_memory, memory_audit, memory_provenance
Retention / hold / consent set_legal_hold, pin, protect, set_consent, retention_policies, retention_decisions, memory_governance
Governance / ops audit, metrics, loops, loop_trace, health, workers_health

Errors are typed: NotFoundError (404), LegalHoldError (409 from a held-memory delete), and APIError (other non-2xx) — all subclasses of MemoryOpsError.

Examples

Runnable scripts in the repo under packages/memoryops-sdk/examples/:

3. Run the server locally (optional)

You only need this to run your own MemoryOps API — SDK users pointing at a hosted API can skip it. Clone the repo, then start the API with the in-memory backend (no infrastructure required):

git clone https://github.com/patibandlavenkatamanideep/memoryops-ai
cd memoryops-ai/services/api
pip install -r requirements.txt
MEMORYOPS_STORAGE=memory uvicorn app.main:app --reload   # serves http://localhost:8000

Then point the client at http://localhost:8000 as in step 2.

Testing / in-process use

Pass any httpx.Client (including FastAPI's TestClient) via http_client= to drive the SDK in-process without a network. This requires a repo checkout so the app package is importable (see step 3):

from fastapi.testclient import TestClient
from app.main import app
from memoryops import MemoryOpsClient

mo = MemoryOpsClient("http://testserver", "t", "u", http_client=TestClient(app))

Run the SDK test suite (from a repo checkout):

cd memoryops-ai/packages/memoryops-sdk && pytest -q

See docs/assistant-sdk.md for the project-level overview.

Metadata

Release files for memoryops-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memoryops-sdk 1.0.0
File Size Uploaded Provenance Actions
memoryops_sdk-1.0.0.tar.gz 16.2 kB Without provenance Details for memoryops_sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for memoryops-sdk 1.0.0
File Interpreter ABI Platform Actions
memoryops_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for memoryops_sdk-1.0.0-py3-none-any.whl

Total release size: 29.1 kB

Release files / memoryops_sdk-1.0.0.tar.gz

Download URL memoryops_sdk-1.0.0.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2ee5f626082152cce336e5060582e9139c412a235f5772f4d585afe1203d64e4
BLAKE2b-256 checksum
How to use checksums
9279ca83e479215a911e2184fd55db4f51793706b8f0bc5b682ebf75552b157e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / memoryops_sdk-1.0.0-py3-none-any.whl

Download URL memoryops_sdk-1.0.0-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64a1119fd6930daaae877cedc16efce6eb036e2c2f48b26529d50376bd22857e
BLAKE2b-256 checksum
How to use checksums
628d7c91c765704e695c6076c9fff5817a6788de6049a4caf5cac8642f6ba3d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for memoryops-sdk 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page