Skip to main content

Python SDK for MemoraLabs — persistent memory for AI agents

Project description

memoralabs

Python SDK for MemoraLabs — persistent, self-improving memory for AI agents.

Store and recall memories in 5 lines of Python. Memory retrieval improves over time using Q-learning and temporal decay, so your agents get smarter, not just bigger.

Installation

pip install memoralabs

Requires Python 3.9+ and installs only one dependency: httpx.

Quick start

from memoralabs import MemoraLabs
client = MemoraLabs(api_key="ml_your_key")
memory = client.add("User prefers dark mode", user_id="user_42")
results = client.search("display preferences", user_id="user_42")
print(results.results[0].text)

Get an API key at memoralabs-api.onrender.com/docs.

All methods

Method Description Returns
signup(name, email, plan) Register a new developer account SignupResponse
rotate_key() Rotate your API key (revokes old key) KeyRotateResponse
add(text, *, user_id, agent_id, session_id, metadata) Store a new memory MemoryResponse
get(memory_id) Retrieve a memory by ID MemoryResponse
list(*, page, per_page, user_id, agent_id, session_id) Paginated list of memories MemoryListResponse
update(memory_id, *, text, metadata) Update a memory's text or metadata MemoryResponse
delete(memory_id) Delete a memory bool
search(query, *, user_id, agent_id, session_id, limit, min_score) Semantic search SearchResponse
gaps() Detect knowledge gaps in stored memories GapResponse
billing_status() Current plan, usage counts, billing dates BillingStatusResponse
checkout(*, success_url, cancel_url) Create a Stripe Checkout session for Pro CheckoutResponse

All optional keyword arguments default to None and are omitted from requests when not provided.

Error handling

from memoralabs import MemoraLabs, AuthError, PlanLimitError, NotFoundError

client = MemoraLabs(api_key="ml_your_key")

try:
    results = client.search("user preferences", user_id="user_42")
except AuthError:
    print("Invalid API key — check your credentials")
except PlanLimitError as e:
    print(f"Plan limit reached. Upgrade at: {e.upgrade_url}")
except NotFoundError:
    print("Memory not found")

All SDK exceptions inherit from MemoraLabsError and expose:

  • status_code — HTTP status returned by the API
  • error_code — Machine-readable error string (e.g. "PLAN_LIMIT_EXCEEDED")
  • message — Human-readable description

Type errors are raised before any HTTP request is made, so you catch mistakes at call time rather than from network responses.

Context manager

with MemoraLabs(api_key="ml_your_key") as client:
    client.add("Session started", user_id="user_42")
# Connection pool released automatically

Namespacing memories

Use user_id, agent_id, and session_id to isolate memories across users, agents, and conversations:

# Store memory for a specific user and agent
client.add(
    "Prefers Python over JavaScript",
    user_id="user_42",
    agent_id="coding-assistant",
    session_id="session_101",
)

# Search only within that user's memories
results = client.search("language preference", user_id="user_42")

Full API reference

memoralabs-api.onrender.com/docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memoralabs-1.0.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memoralabs-1.0.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file memoralabs-1.0.1.tar.gz.

File metadata

  • Download URL: memoralabs-1.0.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for memoralabs-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e697a1bc76f825fbc40249d30a4c2cc6d5991256008b5de8bc0edc3db1e6dbbb
MD5 c3aa2b88f5a77050423ee0a020e7d332
BLAKE2b-256 f36e13e338133a9315a803fe3396f57c058b12323b3f10103f6c29ccc20c2777

See more details on using hashes here.

File details

Details for the file memoralabs-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: memoralabs-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for memoralabs-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 761117bfac83c17df0a3a83b48196d7fa8d49117a2034a6350248b11a2ac3cbb
MD5 e17438e2e2e761c99a93fca41971641a
BLAKE2b-256 89bac14ecfeffba5f9a67e4dba41bedb295c2d0494487677fbb93f0030b05a72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page