Skip to main content
AsyncMemory is the async/await OMP client. It mirrors Memory exactly — same constructor arguments, same method signatures — but every verb is a coroutine that you await. It is designed for use in asyncio-based applications such as FastAPI, LangChain async pipelines, or any async agent framework.

Installation

The async client requires the [async] extras, which pull in asyncpg and httpx:

Import

Importing openmem itself does not load any async dependencies. AsyncMemory is only resolved when you import it. If asyncpg is not installed, the import raises a clear ImportError with the exact install instruction to run.

Constructor

The constructor is identical to Memory:
All provider-specific **config arguments are the same as for Memory. One additional keyword argument is available for async-only tuning:
number
Maximum number of worker threads in the ThreadPoolExecutor used for mem0, supermemory, and letta providers. Defaults to the Python default (min(32, os.cpu_count() + 4)). Ignored by native async providers (postgres, passthrough).

The preferred way to use AsyncMemory is as an async context manager. This ensures connection pools and HTTP clients are cleanly shut down when you are done:
You can also instantiate it manually and call close() explicitly:
Prefer async with over manual close(). It is idempotent and exception-safe.

Methods

All methods on AsyncMemory are coroutines with signatures identical to their Memory counterparts. Every call must be awaited. For full parameter documentation for each method, refer to the Memory class reference. The signatures and return types are identical.

Provider async implementation

Different providers use different strategies to deliver async I/O:
For mem0, supermemory, and letta, the SDK wraps the synchronous adapter in a ThreadPoolExecutor. These providers do not support true async cancellation — asyncio.CancelledError returns control to the awaiter immediately, but the background thread may continue running until the network request completes.

Cross-loop safety

AsyncMemory is bound to the event loop on the first verb call (or __aenter__). If you attempt to use the same instance on a different event loop, it raises:
Do not share an AsyncMemory instance across threads or event loops. Create one instance per event loop. This is enforced at runtime; the error is raised before any backend call is made.

Full example


FastAPI integration example

In FastAPI or any framework with a single long-running event loop, create AsyncMemory once at startup using a lifespan handler and reuse it across requests.