Python SDK for Walrus Memory — Privacy-first AI memory with Ed25519 signing
Project description
Walrus Memory Python SDK
Python SDK for Walrus Memory — Privacy-first AI memory with Ed25519 signing.
All data processing (encryption, embedding, Walrus storage) happens server-side in a TEE. The SDK signs requests with your Ed25519 delegate key and sends text over HTTPS.
Installation
pip install memwal
With optional integrations:
pip install memwal[langchain] # LangChain support
pip install memwal[openai] # OpenAI SDK support
pip install memwal[all] # Everything
Quick Start
Set your environment variables first:
export MEMWAL_PRIVATE_KEY="your-ed25519-delegate-private-key-hex"
export MEMWAL_ACCOUNT_ID="0x-your-walrus-memory-account-id"
export MEMWAL_SERVER_URL="https://relayer.memwal.ai"
MEMWAL_PRIVATE_KEY is the delegate private key from the Walrus Memory dashboard and
must stay server-side.
Async (recommended)
import asyncio
import os
from memwal import MemWal
async def main():
memwal = MemWal.create(
key=os.environ["MEMWAL_PRIVATE_KEY"],
account_id=os.environ["MEMWAL_ACCOUNT_ID"],
server_url=os.environ.get("MEMWAL_SERVER_URL", "https://relayer.memwal.ai"),
)
# Store a memory
result = await memwal.remember("I'm allergic to peanuts")
print(result.blob_id)
# Recall memories
matches = await memwal.recall("food allergies", limit=10, max_distance=0.7)
for memory in matches.results:
print(f"{memory.text} (relevance: {1 - memory.distance:.2f})")
# Analyze conversation for facts
analysis = await memwal.analyze("I love coffee and live in Tokyo")
for fact in analysis.facts:
print(fact.text)
await memwal.close()
asyncio.run(main())
Sync
import os
from memwal import MemWalSync
client = MemWalSync.create(
key=os.environ["MEMWAL_PRIVATE_KEY"],
account_id=os.environ["MEMWAL_ACCOUNT_ID"],
server_url=os.environ.get("MEMWAL_SERVER_URL", "https://relayer.memwal.ai"),
)
result = client.remember("I'm allergic to peanuts")
matches = client.recall("food allergies")
client.close()
Context Manager
import os
from memwal import MemWal
async with MemWal.create(
key=os.environ["MEMWAL_PRIVATE_KEY"],
account_id=os.environ["MEMWAL_ACCOUNT_ID"],
) as memwal:
await memwal.remember("I prefer dark mode")
Environment Presets
Instead of hardcoding a relayer URL, pass env to target a hosted relayer.
Same shorthand as the TypeScript SDK and MCP package.
from memwal import MemWal
memwal = MemWal.create(
key=os.environ["MEMWAL_PRIVATE_KEY"],
account_id=os.environ["MEMWAL_ACCOUNT_ID"],
env="prod", # prod | dev | staging | local
)
env |
Relayer URL |
|---|---|
prod |
https://relayer.memwal.ai |
dev |
https://relayer.dev.memwal.ai |
staging |
https://relayer.staging.memwal.ai |
local |
http://127.0.0.1:8000 |
Precedence: an explicit non-default server_url wins over env, which wins
over the default. An unknown preset raises ValueError. env is also accepted
by MemWalSync.create, with_memwal_langchain, and with_memwal_openai.
AI Middleware
LangChain
import os
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage
from memwal import with_memwal_langchain
llm = ChatOpenAI(model="gpt-4o")
smart_llm = with_memwal_langchain(
llm,
key=os.environ["MEMWAL_PRIVATE_KEY"],
account_id=os.environ["MEMWAL_ACCOUNT_ID"],
server_url=os.environ.get("MEMWAL_SERVER_URL", "https://relayer.memwal.ai"),
max_memories=5,
min_relevance=0.3,
)
# Memories are automatically recalled and injected
response = await smart_llm.ainvoke([HumanMessage("What are my food allergies?")])
OpenAI SDK
import os
from openai import AsyncOpenAI
from memwal import with_memwal_openai
client = AsyncOpenAI()
smart_client = with_memwal_openai(
client,
key=os.environ["MEMWAL_PRIVATE_KEY"],
account_id=os.environ["MEMWAL_ACCOUNT_ID"],
server_url=os.environ.get("MEMWAL_SERVER_URL", "https://relayer.memwal.ai"),
)
# Memories are automatically recalled and injected
response = await smart_client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What are my food allergies?"}],
)
API Reference
MemWal.create(key, account_id, server_url?, namespace?)
Create a new async client.
Methods
| Method | Description |
|---|---|
await remember(text, namespace?) |
Store a memory |
await recall(query, limit?, namespace?, max_distance?) |
Search memories, optionally filtering by distance |
await analyze(text, namespace?) |
Extract and store facts |
await ask(question, limit?, namespace?) |
Ask a question answered using memories |
await restore(namespace, limit?) |
Restore a namespace |
await health() |
Check server health |
await remember_manual(opts) |
Store with pre-computed vector |
await recall_manual(opts) |
Search with pre-computed vector |
await get_public_key_hex() |
Get Ed25519 public key |
Authentication
Every request is signed with Ed25519:
message = f"{timestamp}.{method}.{path_and_query}.{body_sha256}.{nonce}.{account_id}"
Signed requests send x-public-key, x-signature, x-timestamp, x-nonce, and x-account-id. Relayer-mode requests also send x-seal-session; manual-mode requests omit decrypt credentials.
License
MIT
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 memwal-0.1.2.tar.gz.
File metadata
- Download URL: memwal-0.1.2.tar.gz
- Upload date:
- Size: 45.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8820d0477c554c3d2b192d715c74b51356b174d107a18c24dfad730e29cf4d2c
|
|
| MD5 |
64dc255b36329d098c88f546a8008fcd
|
|
| BLAKE2b-256 |
3c35815c6eb0ba8ccb385c920927fc3d8207656231c0d73a22356a48d212b800
|
Provenance
The following attestation bundles were made for memwal-0.1.2.tar.gz:
Publisher:
release-python-sdk.yml on MystenLabs/MemWal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
memwal-0.1.2.tar.gz -
Subject digest:
8820d0477c554c3d2b192d715c74b51356b174d107a18c24dfad730e29cf4d2c - Sigstore transparency entry: 1627973068
- Sigstore integration time:
-
Permalink:
MystenLabs/MemWal@a90a3d970982a0817f041405f4b787ebd08c3f79 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MystenLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-sdk.yml@a90a3d970982a0817f041405f4b787ebd08c3f79 -
Trigger Event:
push
-
Statement type:
File details
Details for the file memwal-0.1.2-py3-none-any.whl.
File metadata
- Download URL: memwal-0.1.2-py3-none-any.whl
- Upload date:
- Size: 26.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeb339ea073f3b8fc9aecfd1e4c2f41ccd54f8680e6c2f1b590acd8ca7c358e8
|
|
| MD5 |
000ebc156f3b13488308ccb2a67d9130
|
|
| BLAKE2b-256 |
5cb8edb86655c4aba04f6b50543e39b4f46b8ed933675fe40213a774528c9ae5
|
Provenance
The following attestation bundles were made for memwal-0.1.2-py3-none-any.whl:
Publisher:
release-python-sdk.yml on MystenLabs/MemWal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
memwal-0.1.2-py3-none-any.whl -
Subject digest:
aeb339ea073f3b8fc9aecfd1e4c2f41ccd54f8680e6c2f1b590acd8ca7c358e8 - Sigstore transparency entry: 1627973078
- Sigstore integration time:
-
Permalink:
MystenLabs/MemWal@a90a3d970982a0817f041405f4b787ebd08c3f79 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MystenLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-sdk.yml@a90a3d970982a0817f041405f4b787ebd08c3f79 -
Trigger Event:
push
-
Statement type: