Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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

Try It In Colab

Open the runnable Walrus Memory Python SDK Colab for a notebook walkthrough covering installation, secure staging configuration, optional prod, health checks, remember, remember_async, async job waiting, recall, bulk remember, remember_bulk_async, remember_bulk_and_wait, optional SDK utilities, OpenAI/LangChain middleware, OpenAI-compatible provider settings such as OPENAI_BASE_URL, and troubleshooting.

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.memory.walrus.xyz"

MEMWAL_PRIVATE_KEY is the delegate private key from the Walrus Memory dashboard and must stay server-side.

import asyncio
import os
from memwal import MemWal, RecallParams

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.memory.walrus.xyz"),
    )

    # Store a memory and wait until the background job is searchable
    result = await memwal.remember_and_wait("I'm allergic to peanuts")
    print(result.blob_id)

    # Recall memories
    matches = await memwal.recall(RecallParams(query="food allergies", limit=10, max_distance=0.8))
    for memory in matches.results:
        print(f"{memory.text} (relevance: {1 - memory.distance:.2f})")

    # Analyze conversation for facts and wait until extracted facts are searchable
    analysis = await memwal.analyze_and_wait("I love coffee and live in Tokyo")
    for fact in analysis.facts:
        print(fact.text)

    await memwal.close()

asyncio.run(main())

0.8 is a starting point for the distance cutoff. Calibrate max_distance against your own memories and query phrasing: lower values reduce noise, while higher values preserve more relevant matches.

Sync

import os
from memwal import MemWalSync, RecallParams

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.memory.walrus.xyz"),
)

result = client.remember_and_wait("I'm allergic to peanuts")
matches = client.recall(RecallParams(query="food allergies"))
client.close()

Offline tests and CI

MemWalMock and MemWalMockSync implement the common memory API in process. They require no credentials, relayer, chain, or paid storage and use deterministic token-overlap ranking.

from memwal import MemWalMock, RecallParams

async def test_memory_flow():
    memwal = MemWalMock.create(namespace="test-user")
    await memwal.remember_and_wait("The user prefers dark mode")

    result = await memwal.recall(RecallParams(query="display preference"))
    assert "dark mode" in result.results[0].text

The mock supports remember/job polling, bulk remember, recall, analyze, embed, ask, health, restore, list_namespaces, forget(blob_id), and clear(namespace). For deterministic behavior, analyze stores its full input as one fact instead of invoking an LLM extractor. Its simple relevance score is for application tests, not production search-quality evaluation.

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_and_wait("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="staging",   # staging for testing, prod for production
)
env Relayer URL
prod https://relayer.memory.walrus.xyz
dev https://relayer.dev.memwal.ai
staging https://relayer-staging.memory.walrus.xyz

Precedence: any explicit server_url wins over env, including the hosted default. env applies only when server_url is omitted (None). 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.memory.walrus.xyz"),
    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.memory.walrus.xyz"),
)

# 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?) Accept a background remember job and return job_id
await get_remember_status(job_id) Read one remember job without waiting
await wait_for_remember_job(job_id, ...) Poll one remember job until it is searchable
await remember_and_wait(text, namespace?, ...) Store a memory and wait until it is searchable
await remember_bulk(items) Accept several background remember jobs
await wait_for_remember_jobs(job_ids, opts?) Poll several remember jobs together
await remember_bulk_and_wait(items, opts?) Store several memories and wait for completion
await recall(RecallParams(query, limit?, namespace?, max_distance?, scoring_weights?, sort?)) 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 list_namespaces(cursor?, limit?) List namespaces that hold memories; paginate on has_more
await health() Check server health
await remember_manual(opts) Store encrypted payload + 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

Metadata

Release files for memwal 0.1.12rc1

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

Source distribution (sdist)

Source distribution for memwal 0.1.12rc1
File Size Uploaded Provenance Actions
memwal-0.1.12rc1.tar.gz 103.0 kB With provenance Details for memwal-0.1.12rc1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for memwal 0.1.12rc1
File Interpreter ABI Platform Actions
memwal-0.1.12rc1-py3-none-any.whl Python 3 none any Details for memwal-0.1.12rc1-py3-none-any.whl

Total release size: 154.1 kB

Release files / memwal-0.1.12rc1.tar.gz

Download URL memwal-0.1.12rc1.tar.gz
Size 103.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8d8a8c50d8bc1b2cd8b3e818d85c9fa57bae958748336dbf47e40a9e204328b1
BLAKE2b-256 checksum
How to use checksums
974fc11555de4905546e957cab4079d483bd566e046713707939aba167987d93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / memwal-0.1.12rc1-py3-none-any.whl

Download URL memwal-0.1.12rc1-py3-none-any.whl
Size 51.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32535cfb06cce430b6b11fc558f32f22ca956438adde7c28c3bc116476c41fa7
BLAKE2b-256 checksum
How to use checksums
f622fb2b2516f8e74ddbeb82df69016bef7d099416a5bd529e9b9088dcf3d9b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for memwal 0.1.12rc1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for memwal-0.1.12rc1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

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
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