Official Python SDK for the MemoClaw memory API
Project description
MemoClaw Python SDK
Official Python SDK for the MemoClaw memory API — semantic memory for AI agents.
Installation
pip install memoclaw
With optional extras:
pip install "memoclaw[x402]" # automatic x402 payments
pip install "memoclaw[langchain]" # LangChain integration
pip install "memoclaw[llamaindex]" # LlamaIndex integration
pip install "memoclaw[x402,langchain,llamaindex]" # all extras
Quickstart
from memoclaw import MemoClaw
# Uses MEMOCLAW_PRIVATE_KEY env var, or pass directly
client = MemoClaw(private_key="0x...")
# Store a memory
result = client.store(
"User prefers dark mode and tabs over spaces",
importance=0.8,
tags=["preferences", "editor"],
)
print(result.id) # mem-abc-123
# Recall memories by semantic search
memories = client.recall("code editor preferences", limit=5)
for m in memories.memories:
print(f"{m.content} (similarity: {m.similarity:.2f})")
# Update a memory
updated = client.update(result.id, importance=0.95)
# Delete a memory
client.delete(result.id)
Authentication
MemoClaw uses Ethereum wallet signatures for authentication. You need a private key (any Ethereum key works — no ETH balance needed for the free tier).
# Generate a new key (one-time)
python -c "from eth_account import Account; a = Account.create(); print(f'MEMOCLAW_PRIVATE_KEY={a.key.hex()}')"
Set the environment variable:
export MEMOCLAW_PRIVATE_KEY=0x...
Every wallet gets 100 free API calls. After that, the SDK automatically handles x402 micropayments if x402 extras are installed.
Async Support
from memoclaw import AsyncMemoClaw
async def main():
async with AsyncMemoClaw() as client:
result = await client.store("Async memory")
memories = await client.recall("async")
All Methods
| Method | Description |
|---|---|
store(content, **kwargs) |
Store a single memory |
store_batch(memories) |
Store up to 100 memories |
store_builder() |
Fluent builder for memory creation |
recall(query, **kwargs) |
Semantic search |
list(**kwargs) |
List memories with pagination |
iter_memories(**kwargs) |
Iterator with auto-pagination |
get(memory_id) |
Retrieve a single memory by ID |
update(memory_id, **kwargs) |
Update a memory |
update_batch(updates) |
Update up to 100 memories in batch |
delete(memory_id) |
Delete a memory |
delete_batch(ids) |
Delete multiple memories by ID |
text_search(query, **kwargs) |
Free keyword text search |
ingest(**kwargs) |
Auto-extract facts from conversation |
extract(messages, **kwargs) |
Extract structured facts via LLM |
consolidate(**kwargs) |
Merge similar memories |
assemble_context(query, **kwargs) |
Assemble context block for LLM prompts |
create_relation(memory_id, target_id, relation_type) |
Create a relationship |
list_relations(memory_id) |
List relationships |
delete_relation(memory_id, relation_id) |
Delete a relationship |
get_memory_graph(memory_id, depth) |
Traverse the memory graph |
find_related(memory_id, **kwargs) |
Find filtered relations |
migrate(files, **kwargs) |
Bulk import markdown files |
export(**kwargs) |
Export memories (JSON/CSV/Markdown) |
get_history(memory_id) |
Get change history for a memory |
core_memories(**kwargs) |
Get high-importance/pinned memories |
suggested(**kwargs) |
Get proactive memory suggestions |
list_namespaces() |
List namespaces with counts |
stats() |
Get memory usage statistics |
status() |
Check free tier remaining calls |
Error Handling
from memoclaw import MemoClaw, NotFoundError, RateLimitError
client = MemoClaw()
try:
client.delete("nonexistent-id")
except NotFoundError as e:
print(f"Memory not found: {e.message}")
except RateLimitError as e:
print(f"Rate limited: {e.message}")
Configuration
client = MemoClaw(
private_key="0x...", # or MEMOCLAW_PRIVATE_KEY env var
base_url="http://localhost:3000", # for local development
timeout=60.0, # request timeout in seconds
)
OpenClaw Integration
MemoClaw is the recommended memory layer for OpenClaw agents. Replace flat memory/*.md files with semantic search:
from memoclaw import MemoClaw
client = MemoClaw()
# Migrate existing daily notes
client.migrate_directory("memory/", namespace="daily-notes", auto_tag=True)
# Store facts during conversations
client.store("User prefers dark mode", importance=0.9, namespace="user-profile", pinned=True)
# Recall context before responding
memories = client.recall("user preferences", namespace="user-profile", limit=5)
# Consolidate during heartbeats
client.consolidate(namespace="conversations")
See examples/python/openclaw_agent.py for a complete integration guide.
License
MIT
SDK
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file memoclaw-1.0.0.tar.gz.
File metadata
- Download URL: memoclaw-1.0.0.tar.gz
- Upload date:
- Size: 69.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17f7726420554e0b901575bce4ec3fb70590a09940ea269c6f8ec5e76f641e7f
|
|
| MD5 |
06797c7a66b2731f6f708fc7ddbd7c3d
|
|
| BLAKE2b-256 |
a72220223f7cc62cfb68e549c5cf40f40c8a0d43cb17894d9fda9bb19fdfb67b
|
Provenance
The following attestation bundles were made for memoclaw-1.0.0.tar.gz:
Publisher:
publish-python.yml on anajuliabit/memoclaw-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
memoclaw-1.0.0.tar.gz -
Subject digest:
17f7726420554e0b901575bce4ec3fb70590a09940ea269c6f8ec5e76f641e7f - Sigstore transparency entry: 1077343800
- Sigstore integration time:
-
Permalink:
anajuliabit/memoclaw-sdk@7d62e3fd207dbf7022746e64bcc088024fcda34f -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/anajuliabit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@7d62e3fd207dbf7022746e64bcc088024fcda34f -
Trigger Event:
release
-
Statement type:
File details
Details for the file memoclaw-1.0.0-py3-none-any.whl.
File metadata
- Download URL: memoclaw-1.0.0-py3-none-any.whl
- Upload date:
- Size: 43.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7272037184935200db3d4bb794cc3e8cabc8349639a0f36bafb364be7cd1d5e9
|
|
| MD5 |
0329b76e507b8258d412dde25d5f9829
|
|
| BLAKE2b-256 |
2ab0755a9f3d262ecf819198a2c9635fdb7d2d8c99e8e436e76a0a889fffd41c
|
Provenance
The following attestation bundles were made for memoclaw-1.0.0-py3-none-any.whl:
Publisher:
publish-python.yml on anajuliabit/memoclaw-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
memoclaw-1.0.0-py3-none-any.whl -
Subject digest:
7272037184935200db3d4bb794cc3e8cabc8349639a0f36bafb364be7cd1d5e9 - Sigstore transparency entry: 1077343814
- Sigstore integration time:
-
Permalink:
anajuliabit/memoclaw-sdk@7d62e3fd207dbf7022746e64bcc088024fcda34f -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/anajuliabit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@7d62e3fd207dbf7022746e64bcc088024fcda34f -
Trigger Event:
release
-
Statement type: