Skip to main content

Search Memory

Returns the most relevant historical memories based on semantic search

Performs a similarity search based on conversation messages and returns relevant memory nodes.

Method and endpoint

POST https://dashscope.aliyuncs.com/api/v2/apps/memory/memory_nodes/search

Request parameters

ParameterTypeRequiredDescription
messagesarrayYesConversation messages used as the query
messages[].rolestringNoMessage role
messages[].contentstring / arrayNoMessage content as a text string or multimodal content array
messages[].content[].typestringNoContent type: text or image_url. Images are parsed only for projects that support multimodal input
messages[].content[].textstringConditionally requiredText content. Required when type is text
messages[].content[].image_urlobjectConditionally requiredImage information. Required when type is image_url
messages[].content[].image_url.urlstringConditionally requiredImage URL
user_idstringYesSub-user ID used to isolate memories
memory_library_idstringNoMemory library ID
project_idstringNoProject ID used for secondary isolation. Mutually exclusive with project_ids
project_idsarray[string]NoMultiple project IDs. Mutually exclusive with project_id
top_kintegerNoMaximum number of results. Default: 10
min_scorenumberNoMinimum score threshold. Results below this score are filtered out. Default: 0.3. Effective only when plan_version is pro
memory_typesarray[string]NoMemory type filter. Valid values: observation and skill. Default: ["observation"]
plan_versionstringNoBilling plan: pro or lite. Default: pro. The value is case-insensitive; other values cause an error
The pro plan supports filtering results by min_score. The lite plan does not use this parameter. See Billing.

Response

FieldTypeDescription
request_idstringRequest ID
plan_versionstringBilling plan used for this search: pro or lite
memory_nodesarrayMemory nodes
memory_nodes[].memory_node_idstringMemory node ID
memory_nodes[].contentstringMemory content
memory_nodes[].timestampintegerTime associated with the memory
memory_nodes[].created_atintegerCreation time
memory_nodes[].updated_atintegerUpdate time
memory_nodes[].media_descstringMultimodal content description
memory_nodes[].meta_dataobjectCustom metadata
memory_nodes[].memory_typestringMemory type
memory_nodes[].statusstringMemory status
memory_nodes[].scorenumberSearch score
memory_nodes[].project_idstringProject ID. Returned when present
memory_nodes[].multimodal_mediasarrayMultimodal resources. Returned when present

Request example

curl --location 'https://dashscope.aliyuncs.com/api/v2/apps/memory/memory_nodes/search' \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "user_id": "user_001",
    "memory_library_id": "memory_library_001",
    "project_ids": ["project_001"],
    "messages": [
      {"role": "user", "content": "What do I have scheduled for 11 AM tomorrow?"}
    ],
    "top_k": 10,
    "min_score": 0.3,
    "memory_types": ["observation"],
    "plan_version": "pro"
  }'

Response example

{
  "request_id": "416f3d78-2bba-9852-ac15-4b3bcee6c7e4",
  "plan_version": "pro",
  "memory_nodes": [
    {
      "memory_node_id": "cafff28fd3a44c04ac5a65d1ea0858b7",
      "content": "The user needs a reminder to order takeout at 11 AM tomorrow",
      "timestamp": 1783267200,
      "created_at": 1783254720,
      "updated_at": 1783254720,
      "media_desc": "",
      "meta_data": {"location_name": "Beijing"},
      "memory_type": "observation",
      "status": "valid",
      "score": 0.651,
      "project_id": "project_001",
      "multimodal_medias": []
    }
  ]
}
To view a paginated memory list, use List Memory.
Managed Agent API
Flow Agent API
Sandbox API
RAG API
ParseX API
Security API
Framework Integration