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.0.tar.gz (7.6 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.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: memoralabs-1.0.0.tar.gz
  • Upload date:
  • Size: 7.6 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.0.tar.gz
Algorithm Hash digest
SHA256 403d3b0ceca08dfe8e681d46f674c8adf2d641c291c8e1a702944b68fed83ac9
MD5 7e9d8e1838beeda0fb1af96562ec5f03
BLAKE2b-256 5c4b0eb2e7ae39ee6141946b0783fdb26bdcf87b9b2069caac55b6eaf3c9a93b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: memoralabs-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2598117968da849f5063e9d1f9d97d8af7753aa514c684014f9fd7154584af9d
MD5 03bc4a317030b9c00799469524450f4e
BLAKE2b-256 a4189b8dbb6d901ecdf07d8459d65fa125e8aaa1eaa136776fe4aa02e958c24f

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