Link Search Menu Expand Document Documentation Menu

Get Message API

Introduced 2.12

Use this API to retrieve message information for conversational search.

To retrieve message information, 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 message by ID

You can retrieve message information by using the message_id.

Endpoints

GET /_plugins/_ml/memory/message/{message_id}

Path parameters

The following table lists the available path parameters.

Parameter Data type Description
message_id String The ID of the message to retrieve.

Example request

GET /_plugins/_ml/memory/message/0m8ya40BfUsSoeNTj-pU

Example response

{
  "memory_id": "gW8Aa40BfUsSoeNTvOKI",
  "message_id": "0m8ya40BfUsSoeNTj-pU",
  "create_time": "2024-02-02T19:01:32.113621539Z",
  "updated_time": "2024-02-02T19:01:32.113621539Z",
  "response": "Hello, this is OpenAI. Here is the answer to your question.",
  "additional_info": {
    "suggestion": "api.openai.com"
  }
}

For information about response fields, see Create Message request fields.

Get all messages within a memory

Use this command to get a list of messages for a certain memory.

Endpoints

GET /_plugins/_ml/memory/{memory_id}/messages

Path parameters

The following table lists the available path parameters.

Parameter Data type Description
memory_id String The ID of the memory for which to retrieve messages.

Query parameters

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

Parameter Data type Description
max_results Integer The maximum number of messages to return. Default is 10.
next_token Integer The index of the first message in the sorted list of messages to return. Messages are ordered by create_time, starting with the oldest message. Default is 0.

Trace messages are not included in the results. To retrieve trace messages, use the Get Message Traces API.

Response body fields

The following table lists the available response fields.

Field Data type Description
memory_id String The memory ID.
message_id String The message ID.
create_time String The time at which the message was created.
updated_time String The time at which the message was last updated.
input String The question in the message (human input).
prompt_template String The prompt template that was used for the message.
response String The answer to the question (generative AI output).
origin String The name of the AI or other system that generated the response.
additional_info Object Any other information that was sent to the origin.
parent_message_id String The ID of the parent message (for trace messages).
trace_number Integer The trace number (for trace messages).
next_token Integer The index of the first message to return in the next page of results. Present only if more results may exist.

Fields that have no value are omitted from the response.

Example request

GET /_plugins/_ml/memory/gW8Aa40BfUsSoeNTvOKI/messages

Example response

{
  "messages": [
    {
      "memory_id": "gW8Aa40BfUsSoeNTvOKI",
      "message_id": "BW8ha40BfUsSoeNT8-i3",
      "create_time": "2024-02-02T18:43:23.566994302Z",
      "updated_time": "2024-02-02T18:43:23.566994302Z",
      "input": "How do I make an interaction?",
      "prompt_template": "Hello OpenAI, can you answer this question?",
      "response": "Hello, this is OpenAI. Here is the answer to your question.",
      "origin": "MyFirstOpenAIWrapper",
      "additional_info": {
        "suggestion": "api.openai.com"
      }
    },
    {
      "memory_id": "gW8Aa40BfUsSoeNTvOKI",
      "message_id": "0m8ya40BfUsSoeNTj-pU",
      "create_time": "2024-02-02T19:01:32.113621539Z",
      "updated_time": "2024-02-02T19:01:32.113621539Z",
      "response": "Hello, this is OpenAI. Here is the answer to your question.",
      "additional_info": {
        "suggestion": "api.openai.com"
      }
    }
  ]
}