Long-term memory API
AI forgets key information in long conversations and has no memory across sessions, causing context loss and an inconsistent experience. The long-term memory API automatically extracts and stores factual memories and user profiles from historical conversations in a structured way. In subsequent conversations or new sessions, these memories can be retrieved and injected into prompts, enabling the AI to achieve truly continuous understanding.
Memory (long-term memory) provides a complete set of open APIs covering the writing, searching, updating, and deletion of memory nodes, as well as profile schema management and user profile retrieval. All endpoints are served through the workspace-dedicated domain at https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/. Replace {WorkspaceId} with your actual workspace ID. The endpoints use API Key authentication, and the API key must belong to the same workspace. See Authentication.
API overview
Memory management:
| API | Method | Path | Description |
|---|---|---|---|
| AddMemory | POST | /add | Add memories with automatic key information extraction |
| AddMemoryAsync | POST | /add-async | Submit a memory extraction task asynchronously |
| GetEvent | GET | /events/{event_id} | Get asynchronous task event details |
| ListMemory | GET | /memory_nodes | List memory nodes with pagination |
| SearchMemory | POST | /memory_nodes/search | Search memory nodes by similarity, factual memories only by default |
| GetMemoryNode | GET | /memory_nodes/{memory_node_id} | Get a memory node |
| GetSkillExport | GET | /skill/export/{memory_node_id} | Export a skill memory node |
| UpdateMemory | PATCH | /memory_nodes/{memory_node_id} | Update the content of a memory node |
| DeleteMemory | DELETE | /memory_nodes/{memory_node_id} | Delete a memory node |
User profile:
| API | Method | Path | Description |
|---|---|---|---|
| CreateProfileSchema | POST | /profile_schemas | Create a profile schema |
| ListProfileSchemas | GET | /profile_schemas | List profile schemas |
| GetProfileSchema | GET | /profile_schemas/{profile_schema_id} | Get profile schema details |
| UpdateProfileSchema | PATCH | /profile_schemas/{profile_schema_id} | Update a profile schema |
| GetUserProfile | GET | /profile_schemas/{profile_schema_id}/user_profile | Get a user profile |
Minimal call examples
Write a memory (AddMemory):
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/add \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"messages": [
{"role": "user", "content": "Remind me to drink water at 9 AM every day."},
{"role": "assistant", "content": "Sure, I'll remember that."}
],
"user_id": "user_001"
}'
Search memories (SearchMemory):
curl -X POST https://{WorkspaceId}.cn-beijing.maas.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",
"messages": [
{"role": "user", "content": "What do I need to do?"}
]
}'
Usage limits
All APIs combined must not exceed 3,000 QPM (per Alibaba Cloud account). The add API is limited to 120 QPM, and the search API to 300 QPM. For more information, see Rate limits.
ImportantFor per-API request parameters, responses, and Python examples, see the Long-term memory API reference. For an end-to-end walkthrough, see Quickstart. For features and console operations, see Memory.