MemorySync
SDKs · Python

Python SDK

Use the official Python package from Python 3.9 or newer. Start with the synchronous memory client, choose the async client for asyncio code, and use the separate control-plane client for bearer-authenticated administration.

Package at a glance

ItemContract
Installpip install memorysync==1.9.2
RuntimePython 3.9+
Memory clientsMemorySyncClient, AsyncMemorySyncClient
Control-plane clientsControlPlaneClient, AsyncControlPlaneClient
ErrorsSix typed exceptions derived from MemorySyncError

Choose a Python client

Which call style fits your application?

Script, job, or synchronous web code

Your code calls blocking functions and does not use asyncio.

Use: MemorySyncClient.

Async web service or asyncio worker

Your request path already uses async and await.

Use: AsyncMemorySyncClient.

Account or organization administration

The operation uses a bearer session rather than a memory API key.

Use: ControlPlaneClient or AsyncControlPlaneClient.

Import the public surface

clients.py
from memorysync import (
MemorySyncClient,
AsyncMemorySyncClient,
ControlPlaneClient,
AsyncControlPlaneClient,
Memory,
AddSkippedResponse,
MemorySyncError,
AuthError,
ValidationError,
NotFoundError,
RateLimitError,
ServerError,
)

The memory loop

Python memory loop
  1. 01

    Create

    Initialize one client with an API key and trusted scope.

  2. 02

    Add

    Submit one durable fact and inspect created or skipped.

  3. 03

    Query

    Ask for relevant context in the same scope.

  4. 04

    Use

    Select returned records for the current application task.

  5. 05

    Close

    Use a context manager or call the matching close method.

Python conventions

  • Methods and arguments use snake_case, such as bulk_add, end_user_id, and memory_ids.
  • Memory responses are dataclasses; control-plane responses are typed dictionaries.
  • Synchronous methods return values directly; asynchronous methods return the same logical results through await.
  • Optional response fields may be absent or None; read only fields needed by the task.

Build with Python

Was this page helpful?