Documentation Index
Fetch the complete documentation index at: https://docs.openmem.blog/llms.txt
Use this file to discover all available pages before exploring further.
AsyncMemory gives you the full OMP verb set — add, search, context, list, update, delete, audit, and capabilities — as coroutines. It is a drop-in async counterpart to Memory: method names, parameters, and error semantics are identical; the only difference is that every call is awaitable. Use AsyncMemory in any application that runs an event loop, including FastAPI, aiohttp, and scripts driven by asyncio.run.
Install
AsyncMemory is not included in the default openmem install. Add the [async] extra:
Basic usage
Useasync with to open a connection, run your operations, and release resources automatically when the block exits.
Context manager vs. manual lifecycle
async with form is preferred. It guarantees close() is called even when an exception occurs, and it binds the instance to the current event loop at entry time, which makes cross-loop misuse detectable early.
Provider async implementation
Different providers use different async strategies under the hood. The behavior visible to your application is the same, but cancellation semantics vary.| Provider | Async implementation |
|---|---|
postgres | Native asyncpg client |
passthrough (native OMP server) | Native httpx async client |
mem0 / supermemory / letta | Thread pool wrapper |
Cancellation behavior
For Postgres and passthrough, cancellation propagates within 50 ms and the connection pool is reclaimed. For mem0, Supermemory, and Letta, the event loop returns to the awaiter immediately, but the underlying thread continues running until the HTTP request completes. The backend may have observable side-effects.
FastAPI integration
AsyncMemory is a natural fit for FastAPI dependency injection. Create a new instance per request using a dependency so each request gets a properly scoped connection.
AsyncMemory instance in a lifespan context and sharing it across requests — Postgres and passthrough manage an internal connection pool, so concurrent requests are safe.