SDKs

Python SDK

Connect Python apps to the recommended MemexAI service.

Install

From the repository root:

python3 -m pip install -e "sdks/python[test]"

Usage

MemexAI connects to the containerized MemexAI service over HTTP. Recommended for most apps.

from memexai import MemexAI

memex = MemexAI(
    url="http://localhost:8080",
    api_key="dev-agent-key",
)

memory = memex.for_user("user_123", actor="assistant")
await memory.write_file(
    "user/profile.md",
    "# Profile\n\n- Prefers quiet neighborhoods.",
    reason="captured preference",
)

result = await memory.read_file("user/profile.md")
print(result["content"])

await memex.close()

Helpers

await memory.list_files(prefix="user/")
await memory.read_file("user/profile.md")
await memory.write_file("user/profile.md", "# Profile", reason="initial write")
await memory.patch_file(
    "user/profile.md",
    "append_lines",
    after_heading="# Profile",
    lines=["- Likes good tests"],
    reason="new preference",
)
await memory.find("quiet neighborhoods")
await memory.remember("Remember that the user prefers quiet neighborhoods.")

Framework adapters

FrameworkPage
LangChainLangChain adapter
LlamaIndexLlamaIndex adapter
CrewAICrewAI adapter

On this page