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
| Item | Contract |
|---|---|
| Install | pip install memorysync==1.9.2 |
| Runtime | Python 3.9+ |
| Memory clients | MemorySyncClient, AsyncMemorySyncClient |
| Control-plane clients | ControlPlaneClient, AsyncControlPlaneClient |
| Errors | Six 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
from memorysync import (MemorySyncClient,AsyncMemorySyncClient,ControlPlaneClient,AsyncControlPlaneClient,Memory,AddSkippedResponse,MemorySyncError,AuthError,ValidationError,NotFoundError,RateLimitError,ServerError,)
The memory loop
- 01
Create
Initialize one client with an API key and trusted scope.
- 02
Add
Submit one durable fact and inspect created or skipped.
- 03
Query
Ask for relevant context in the same scope.
- 04
Use
Select returned records for the current application task.
- 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, andmemory_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
Install, configure, add, and query in one copy-ready program.
See all 31 memory methods and response variants.
Use native async methods and deterministic cleanup.
Use all 43 named control-plane methods, including public credential exchanges and bearer-authenticated administration.