> ## 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.

# OMP Python SDK type reference

> Reference for all Pydantic v2 models returned by the openmem SDK, including MemoryRecord, SearchResult, ContextBlock, Capabilities, and AuditEntry.

All types returned by the OMP Python SDK are Pydantic v2 models. You can import them directly from the top-level `openmem` package for use in type hints, serialization, or validation. The models mirror the schemas defined in the OMP OpenAPI spec and are the single source of truth for all field names and types.

```python theme={null}
from openmem import (
    MemoryRecord,
    MemorySource,
    SearchResult,
    MemoryPage,
    ContextBlock,
    Capabilities,
    CapabilityFeatures,
    CapabilityLimits,
    AuditEntry,
)
```

<Note>
  All models extend a shared base that sets `extra="allow"`. Unknown fields from future spec versions and provider-specific `x-<provider>` extension fields are preserved on the model instance without raising a validation error.
</Note>

***

## MemoryRecord

`MemoryRecord` is the alias for `openmem.types.Memory`. It is returned by `add()`, `get()`, `update()`, and in paginated lists from `list()`.

<ResponseField name="id" type="string" required>
  Provider-assigned unique identifier for this memory, e.g. `"mem_abc123"`.
</ResponseField>

<ResponseField name="content" type="string" required>
  The text content of the memory.
</ResponseField>

<ResponseField name="user_id" type="string" required>
  The user this memory belongs to.
</ResponseField>

<ResponseField name="created_at" type="datetime" required>
  ISO 8601 timestamp of when the memory was created.
</ResponseField>

<ResponseField name="scope" type="string | None">
  Slash-delimited namespace, e.g. `"coding/preferences"`. `None` if not set.
</ResponseField>

<ResponseField name="tags" type="string[] | None">
  Free-form labels associated with this memory.
</ResponseField>

<ResponseField name="source" type="MemorySource | None">
  Origin information. See [MemorySource](#memorysource).
</ResponseField>

<ResponseField name="confidence" type="number | None">
  Confidence score between `0` and `1`. Higher values indicate greater certainty.
</ResponseField>

<ResponseField name="valid_from" type="datetime | None">
  Datetime at which this memory becomes valid. `None` means immediately.
</ResponseField>

<ResponseField name="valid_to" type="datetime | None">
  Datetime at which this memory expires. `None` means no expiry.
</ResponseField>

<ResponseField name="supersedes" type="string[] | None">
  IDs of memories that this memory replaces.
</ResponseField>

<ResponseField name="embedding_model" type="string | None">
  The model used to generate the memory's embedding, e.g. `"text-embedding-3-small"`. Set by the provider.
</ResponseField>

<ResponseField name="updated_at" type="datetime | None">
  ISO 8601 timestamp of the last update to this memory.
</ResponseField>

<ResponseField name="status" type="&#x22;queued&#x22; | &#x22;indexing&#x22; | &#x22;done&#x22; | &#x22;failed&#x22; | None">
  Ingestion status. Relevant for async-ingestion providers (mem0, supermemory) where memories may be queued before being searchable. `None` on providers with synchronous ingestion.
</ResponseField>

***

## MemorySource

Describes the origin of a memory. All fields are optional.

<ResponseField name="app" type="string | None">
  Name of the application that created the memory, e.g. `"cursor"` or `"chatbot"`.
</ResponseField>

<ResponseField name="type" type="&#x22;extracted&#x22; | &#x22;explicit&#x22; | &#x22;imported&#x22; | None">
  How the memory was created:

  * `"extracted"` — inferred from a conversation or document
  * `"explicit"` — provided directly by the user
  * `"imported"` — migrated from another system
</ResponseField>

<ResponseField name="ref" type="string | None">
  An opaque pointer back to the source artifact, such as a session ID or document ID.
</ResponseField>

***

## SearchResult

Returned as an element in the list from `search()`.

<ResponseField name="memory" type="MemoryRecord" required>
  The matched memory record.
</ResponseField>

<ResponseField name="score" type="number" required>
  Cosine similarity score between `0` and `1`. Higher values indicate greater similarity to the query.
</ResponseField>

***

## MemoryPage

Returned by `list()`. Carries a page of records and a cursor for continuation.

<ResponseField name="items" type="MemoryRecord[]" required>
  The memories in this page.
</ResponseField>

<ResponseField name="next_cursor" type="string | None">
  An opaque pagination cursor. Pass this as `cursor=` to the next `list()` call to retrieve the following page. `None` means you have reached the last page.
</ResponseField>

**Pagination example:**

```python theme={null}
cursor = None
while True:
    page = mem.list(user_id="u1", limit=50, cursor=cursor)
    for m in page.items:
        process(m)
    if page.next_cursor is None:
        break
    cursor = page.next_cursor
```

***

## ContextBlock

Returned by `context()`. Contains a ranked text string ready to inject directly into an LLM prompt.

<ResponseField name="text" type="string" required>
  Pre-ranked text assembled from the most relevant memories, formatted for direct inclusion in a system or user prompt.
</ResponseField>

<ResponseField name="citations" type="object[]" required>
  A list of citation objects, each with:

  * `memory_id` (string) — the ID of the source memory
  * `score` (float) — its relevance score
</ResponseField>

<ResponseField name="token_count" type="number | None">
  The approximate token count of `text`, if the provider reports it. `None` when not available.
</ResponseField>

**Usage in a prompt:**

```python theme={null}
ctx = mem.context(query="set up a new Node project", user_id="u1", token_budget=400)

messages = [
    {
        "role": "system",
        "content": f"Relevant user memory:\n{ctx.text}",
    },
    {"role": "user", "content": user_message},
]
```

***

## Capabilities

Returned by `capabilities()`. Describes what the provider supports so your application can degrade gracefully.

<ResponseField name="omp_version" type="string" required>
  The OMP specification version this provider implements, e.g. `"0.1"`.
</ResponseField>

<ResponseField name="provider" type="string" required>
  The provider's own identifier string, e.g. `"postgres"` or `"mem0"`.
</ResponseField>

<ResponseField name="verbs" type="string[]" required>
  List of supported verb names: `add`, `search`, `get`, `update`, `delete`, `list`, `context`, `audit`.
</ResponseField>

<ResponseField name="features" type="CapabilityFeatures" required>
  Feature flags. See [CapabilityFeatures](#capabilityfeatures).
</ResponseField>

<ResponseField name="limits" type="CapabilityLimits | None">
  Rate and size limits. See [CapabilityLimits](#capabilitylimits).
</ResponseField>

***

## CapabilityFeatures

Nested inside `Capabilities.features`.

<ResponseField name="vector_search" type="boolean | None">
  Whether the provider supports semantic (vector) search.
</ResponseField>

<ResponseField name="keyword_search" type="boolean | None">
  Whether the provider supports keyword (BM25 / full-text) search.
</ResponseField>

<ResponseField name="graph_queries" type="boolean | None">
  Whether the provider supports graph-based queries.
</ResponseField>

<ResponseField name="temporal" type="boolean | None">
  Whether the provider supports time-range filtering.
</ResponseField>

<ResponseField name="scopes" type="&#x22;native&#x22; | &#x22;tags&#x22; | &#x22;none&#x22; | None">
  How the provider implements scopes:

  * `"native"` — first-class scope support
  * `"tags"` — scopes emulated via tags
  * `"none"` — no scope support
</ResponseField>

<ResponseField name="max_content_length" type="number | None">
  Maximum number of characters allowed in `content`. `None` means no declared limit.
</ResponseField>

<ResponseField name="supports_e2e" type="boolean | None">
  Whether the provider supports end-to-end encryption.
</ResponseField>

<ResponseField name="supports_audit" type="boolean | None">
  Whether the provider supports the `audit()` verb.
</ResponseField>

<ResponseField name="supports_supersession" type="boolean | None">
  Whether the provider supports the `supersedes` field on memories.
</ResponseField>

***

## CapabilityLimits

Nested inside `Capabilities.limits`. `None` when the provider does not declare limits.

<ResponseField name="rate_limit_per_minute" type="number | None">
  Maximum number of API calls allowed per minute. `None` means not declared.
</ResponseField>

<ResponseField name="max_search_results" type="number | None">
  Maximum value accepted for the `limit` parameter on `search()`. `None` means not declared.
</ResponseField>

***

## AuditEntry

Each element in the list returned by `audit()`.

<ResponseField name="timestamp" type="datetime | None">
  When the operation occurred.
</ResponseField>

<ResponseField name="app" type="string | None">
  The app that performed the operation.
</ResponseField>

<ResponseField name="action" type="&#x22;add&#x22; | &#x22;search&#x22; | &#x22;get&#x22; | &#x22;update&#x22; | &#x22;delete&#x22; | &#x22;list&#x22; | &#x22;context&#x22; | None">
  The OMP verb that was invoked.
</ResponseField>

<ResponseField name="memory_id" type="string | None">
  The ID of the memory involved, if applicable.
</ResponseField>

<ResponseField name="scope" type="string | None">
  The scope active at the time of the operation.
</ResponseField>

<ResponseField name="request_id" type="string | None">
  The provider-assigned request ID for tracing.
</ResponseField>

***

## Extension fields

Every model uses `extra="allow"`, which means provider-specific `x-<provider>` fields are silently preserved when the SDK receives them from the provider. For example, a memory returned by the mem0 adapter may include an `x-mem0` key with graph metadata; that field round-trips transparently on the `MemoryRecord` instance without breaking validation.

```python theme={null}
record = mem.get("mem_abc123")

# Standard fields
print(record.content)

# Provider extension (if present)
print(record.model_extra.get("x-mem0"))
```
