TheDocumentation Index
Fetch the complete documentation index at: https://docs.openmem.blog/llms.txt
Use this file to discover all available pages before exploring further.
Memory class is the synchronous OMP client. You instantiate it once with a provider string and any provider-specific configuration, then call its methods — add, search, get, update, delete, list, context, audit, and capabilities — the same way regardless of which backend is underneath. Swapping providers requires only changing the constructor arguments; all method calls remain identical.
Constructor
provider argument is a string that selects the backend adapter. The remaining keyword arguments are forwarded directly to that adapter.
Selects the memory backend. Accepted values:
"postgres", "mem0", "supermemory", "letta". Pass base_url= pointing to any OMP-native HTTP server and the SDK will auto-detect it as a passthrough provider regardless of this string.**config keyword arguments depend on which provider you choose:
postgres
postgres
PostgreSQL connection string, e.g.
"postgresql://localhost/omp". Also accepted as dsn=.An embedder instance. Defaults to a lightweight offline embedder that uses zero vectors — suitable for testing without an OpenAI key. Pass
use_openai=True to use OpenAI embeddings instead, or supply a custom embedder object.When
True and no embedder= is supplied, initializes an OpenAIEmbedder automatically.mem0
mem0
supermemory
supermemory
Methods
add()
Store a new memory for a user.The text content of the memory. Must be a non-empty string.
Identifies the user this memory belongs to. All subsequent reads and searches are scoped to this user.
Slash-delimited hierarchy that organizes the memory, e.g.
"coding/preferences" or "health/symptoms". Scopes enable fine-grained consent and filtering.Free-form labels for filtering, e.g.
["tooling", "nodejs"]. Supported by all providers; used as a fallback for scopes on providers where features.scopes == "tags".Origin information for the memory. Accepts a
MemorySource instance or a plain dict with app, type, and/or ref keys. See MemorySource.A float between
0 and 1 indicating confidence in this memory. Higher values indicate higher certainty.ISO 8601 datetime at which this memory becomes valid.
None means immediately.ISO 8601 datetime at which this memory expires.
None means no expiry.A list of memory IDs that this new memory replaces. The referenced memories are retained but semantically superseded.
MemoryRecord containing the provider-assigned id and all stored fields.
search()
Find memories semantically relevant to a query string.The natural-language query to search against stored memories.
Restricts results to memories belonging to this user.
Restrict results to memories under this scope prefix, e.g.
"coding/*".Maximum number of results to return. Subject to the provider’s
limits.max_search_results cap.Minimum similarity score (0..1) for a result to be included. Omit to return the top
limit results regardless of score.SearchResult objects, each containing a memory and a score.
get()
Fetch a single memory by its provider-assigned ID.The provider-assigned memory ID, e.g.
"mem_abc123".MemoryRecord. Raises NotFoundError if the ID does not exist.
update()
Partially update a memory’s fields. Only the fields you provide are changed.The ID of the memory to update.
Replacement text content.
New scope path to move the memory to.
Replacement tag list. Replaces all existing tags.
Updated confidence score (0..1).
New expiry datetime.
Additional IDs of memories superseded by this one.
MemoryRecord.
delete()
Permanently delete a memory.The ID of the memory to delete.
None on success. Raises NotFoundError if the ID does not exist.
list()
List memories for a user, optionally filtered by scope, tag, or time range. Results are paginated.The user whose memories to list.
Filter to memories under this scope prefix.
Filter to memories with this exact tag.
Return only memories created at or after this datetime.
Return only memories created before this datetime.
Maximum number of records per page.
Opaque pagination cursor from a previous
MemoryPage.next_cursor. Pass None to start from the beginning.MemoryPage. When next_cursor on the result is non-None, pass it back as cursor= to fetch the next page.
context()
Retrieve a pre-ranked, prompt-ready text block for injecting into an LLM prompt.The user’s current query or intent used to rank memories for relevance.
The user whose memories to draw from.
Restrict context retrieval to memories under this scope.
Approximate maximum number of tokens for the returned
text. The provider fits as many high-scoring memories as possible within this budget.ContextBlock with a text field ready for prompt injection, citations linking back to source memories, and an optional token_count.
audit()
Retrieve the audit log of operations performed on a user’s memories.Audit log support depends on the provider. Check
caps.features.supports_audit before calling this method.The user whose audit log to retrieve.
Filter to entries originating from this app name.
Return only entries at or after this datetime.
Maximum number of entries to return.
AuditEntry objects, each describing a single operation.
capabilities()
Retrieve the provider’s declared capabilities.Capabilities object describing which verbs and features the provider supports. The result is cached for the lifetime of the Memory instance — the network call is made at most once per session.
Use this to conditionally enable features at runtime:
Full example
AsyncMemory has identical method signatures to Memory, but every method is a coroutine and must be awaited. See AsyncMemory.