Get a memory

Introduced 2.12

Use this API to retrieve a conversational memory for conversational search.

To retrieve memory information, you can:

To retrieve message information for a memory, you can:

When the Security plugin is enabled, all memories exist in a private security mode. Only the user who created a memory can interact with that memory and its messages.

Get a memory by ID

You can retrieve memory information by using the memory_id. The response includes all messages within the memory.

Path and HTTP methods

  1. GET /_plugins/_ml/memory/<memory_id>

Path parameters

The following table lists the available path parameters.

ParameterData typeDescription
memory_idStringThe ID of the memory to retrieve.

Example request

  1. GET /_plugins/_ml/memory/N8AE1osB0jLkkocYjz7D

copy

Example response

  1. {
  2. "memory_id": "gW8Aa40BfUsSoeNTvOKI",
  3. "create_time": "2024-02-02T18:07:06.887061463Z",
  4. "updated_time": "2024-02-02T19:01:32.121444968Z",
  5. "name": "Conversation for a RAG pipeline",
  6. "user": "admin"
  7. }

Get all memories

Use this command to get all memories.

Path and HTTP methods

  1. GET /_plugins/_ml/memory

Query parameters

Use the following query parameters to customize your results. All query parameters are optional.

ParameterData typeDescription
max_resultsIntegerThe maximum number of results to return. If there are fewer memories than the number set in max_results, the response returns only the number of memories that exist. Default is 10.
next_tokenIntegerThe index of the first memory in the sorted list of memories to return. Memories are ordered by create_time. For example, if memories A, B, and C exist, next_token=1 returns memories B and C. Default is 0 (return all memories).

Paginating results

The next_token parameter provides the ordered position of the first memory within the sorted list of memories to return in the results. When a memory is added between subsequent GET Memory calls, one of the listed memories will be duplicated in the results. For example, suppose the current ordered list of memories is BCDEF, where B is the memory created most recently. When you call the Get Memory API with next_token=0 and max_results=3, the API returns BCD. Suppose you then create another memory A. The memory list now appears as ABCDEF. The next time you call the Get Memory API with next_token=3 and max_results=3, you’ll receive DEF in the results. Notice that D will be returned in the first and second batches of results. The following diagram illustrates the duplication.

RequestList of memories (returned memories are enclosed in brackets)Results returned in the response
Get Memory (next_token = 0, max_results = 3)[BCD]EFBCD
Create MemoryABCDEF-
Get Memory (next_token = 3, max_results = 3) -> ABC[DEF]DEF 

Example request: Get all memories

  1. GET /_plugins/_ml/memory/

copy

Example request: Paginating results

  1. GET /_plugins/_ml/memory?max_results=2&next_token=1

Example response

  1. {
  2. "memories": [
  3. {
  4. "memory_id": "gW8Aa40BfUsSoeNTvOKI",
  5. "create_time": "2024-02-02T18:07:06.887061463Z",
  6. "updated_time": "2024-02-02T19:01:32.121444968Z",
  7. "name": "Conversation for a RAG pipeline",
  8. "user": "admin"
  9. }
  10. ]
  11. }

Response fields

The following table lists the available response fields.

FieldData typeDescription
memory_idStringThe memory ID.
create_timeStringThe time at which the memory was created.
updated_timeStringThe time at which the memory was last updated.
nameStringThe memory name.
userStringThe username of the user who created the memory.