Skip to main content

MemoryX Python SDK - Give your AI agents long-term memory

Project description

🧠 MemoryX Python SDK

PyPI version Python License: MIT

Give your AI agents long-term memory in 2 lines of code.

MemoryX is a cloud-native memory layer for AI agents. It provides semantic search, automatic categorization, and project-level memory sharing across multiple agents.

✨ Features

  • 🚀 Zero Config - Auto-registration, no API key management needed
  • 🔍 Semantic Search - Find memories by meaning, not keywords
  • 🤖 Multi-Agent Support - Multiple agents share memories within a project
  • 📊 Auto Categorization - Memories are automatically classified (semantic, episodic, etc.)
  • 🔐 Secure by Design - Machine fingerprint authentication, no passwords
  • ☁️ Cloud Sync - Memories stored securely in the cloud
  • 📦 Zero Dependencies - Uses only Python standard library

📦 Installation

pip install t0ken-memoryx

🚀 Quick Start

from memoryx import connect_memory

# Connect - auto-registers on first use
memory = connect_memory()

# Store memories (async, non-blocking)
memory.send_memories([
    {"content": "User prefers dark mode in VSCode"},
    {"content": "User's project uses TypeScript and React"},
])

# Search memories semantically
results = memory.search("coding preferences")
for m in results["data"]:
    print(f"- {m['content']} (score: {m['score']})")

🎯 Use Cases

AI Assistants

# Remember user preferences across sessions
memory.send_memories([
    {"content": "User prefers concise answers without code comments"},
    {"content": "User works in fintech industry"},
])

# Later, in another session...
results = memory.search("communication style")

Multi-Agent Systems

# Agent 1: VSCode Extension
memory_vscode = APIClient()
memory_vscode.auto_register("vscode", "my-extension")
memory_vscode.send_memories([{"content": "User is debugging auth module"}])

# Agent 2: CLI Tool (same machine, shares project)
memory_cli = APIClient()
memory_cli.auto_register("cli", "my-cli")
# Can search memories stored by VSCode agent!
results = memory_cli.search("debugging")

Conversation Memory

# Store conversation for later analysis
memory.send_conversation("conv-123", [
    {"role": "user", "content": "I need help with my React app"},
    {"role": "assistant", "content": "Sure, what's the issue?"},
    {"role": "user", "content": "The useState hook isn't updating"},
])

📖 API Reference

connect_memory(base_url=None, verbose=True)

Quick connect with auto-registration.

from memoryx import connect_memory

memory = connect_memory()  # First time: auto-registers
# Output: MemoryX activated
#         Agent ID: openclaw-abc12345

APIClient(config)

Advanced usage with explicit configuration.

from memoryx import APIClient

client = APIClient({
    "api_key": "mx_ope_xxx",  # Optional: use existing key
    "api_base_url": "https://t0ken.ai/api"  # Optional: self-hosted
})

# Auto-register new agent
result = client.auto_register("my-agent", "Agent Name")
print(result["agent_id"])  # my-agent-abc12345
print(result["api_key"])   # mx_myagent_xxx

send_memories(memories)

Store memories (batch supported).

# Single memory
result = client.send_memories([
    {"content": "User likes pizza", "metadata": {"category": "preference"}}
])

# Batch memories
result = client.send_memories([
    {"content": "User's timezone is UTC+8"},
    {"content": "User speaks English and Chinese"},
])
print(result["task_id"])  # Async task ID

search(query, limit=10)

Semantic search across all project memories.

results = client.search("food preferences", limit=5)
for m in results["data"]:
    print(f"- {m['content']} (category: {m['category']}, score: {m['score']})")

list(limit=50, offset=0)

List memories with pagination.

memories = client.list(limit=20, offset=0)
print(f"Total: {memories['total']}")

delete(memory_id)

Delete a memory.

client.delete("memory_abc123")

get_task_status(task_id)

Check async task status.

status = client.get_task_status("task_abc123")
print(status["status"])  # PENDING, STARTED, SUCCESS, FAILURE

get_quota()

Get account quota.

quota = client.get_quota()
print(f"Plan: {quota['quota']['tier']}")
print(f"Searches remaining: {quota['quota']['cloud_search']['remaining']}")

🔒 Security

  • Machine Fingerprint: Uses MAC address + hardware info for authentication
  • No Passwords: API keys are auto-generated and tied to agents
  • Project Isolation: Each machine gets its own project, memories are isolated

🌐 Self-Hosted

from memoryx import connect_memory

memory = connect_memory(base_url="http://your-server:8000/api")

📚 More Resources

📄 License

MIT © MemoryX Team

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

t0ken_memoryx-2.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

t0ken_memoryx-2.1.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file t0ken_memoryx-2.1.1.tar.gz.

File metadata

  • Download URL: t0ken_memoryx-2.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for t0ken_memoryx-2.1.1.tar.gz
Algorithm Hash digest
SHA256 8a4a5440cf5c098a4f2bced49abadd2a763920bd667d6f4ddbe59d4641fb9a5e
MD5 3aa95f865264b88c7a17df2b052153fc
BLAKE2b-256 06112ff58f2c666b29986c966500fdb7f14ba6bda3e9848d17635accee69a494

See more details on using hashes here.

File details

Details for the file t0ken_memoryx-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: t0ken_memoryx-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for t0ken_memoryx-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 95554d956cc9959213f1158c852f500b9ac3340337a187e362ee60c872919332
MD5 5e5d2971e8d244a47f6d66a637ff9fa4
BLAKE2b-256 e10b8bf2f435772d642b23f8587ab9013ee30139ceddd197d0a046d90a65e895

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