The long-term memory API enables writing, searching, updating, and deletion of memories, as well as profile schema management and user profile retrieval, served through the workspace-dedicated domain.
Common Request Information
| Parameter | Description |
|---|---|
| Base URL | https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/. Replace {workspaceId} in the request URL with your actual workspace ID, and use an API key that belongs to the same workspace. |
| Authentication | Add Authorization: Bearer $DASHSCOPE_API_KEY to the request header. See the API Key management page for obtaining a key |
| Content-Type | application/json |
Before using the long-term memory API, you must enable the memory service in the console. Without activation, AddMemory and SearchMemory return a
ServiceNotOpened error.API Overview
Factual Memory
| API | Method | Path | Description |
|---|---|---|---|
| AddMemory | POST | /add | Add memories with automatic key information extraction |
| ListMemory | GET | /memory_nodes | List memories with pagination |
| SearchMemory | POST | /memory_nodes/search | Search historical memories based on semantics |
| UpdateMemory | PATCH | /memory_nodes/{memory_node_id} | Update memory content |
| DeleteMemory | DELETE | /memory_nodes/{memory_node_id} | Delete a memory node |
User Profiles
| API | Method | Path | Description |
|---|---|---|---|
| CreateProfileSchema | POST | /profile_schemas | Create a profile schema |
| GetUserProfile | GET | /profile_schemas/{schema_id}/user_profile | Get the user profile for the specified schema |
Error Codes
| Code | HTTP | Description |
|---|---|---|
ServiceNotOpened | 400 | Memory service not activated |
MemoryNodeNotFound | 404 | Memory node does not exist |
InvalidApiKey | 401 | Invalid API key |
Throttling.RateQuota | 429 | Rate limit exceeded |
API Authentication
AddMemory
Add memories to the memory store, either from conversation messages (with automatic extraction) or as custom content.
Request
| Parameter | Type | Required | Description |
|---|---|---|---|
| messages | array | Yes (when using conversation) | The conversation messages. |
| custom_content | string | Yes (when using custom) | Custom memory content. |
| user_id | string | Yes | The user identifier for the memory space. |
| memory_library_id | string | No | The memory store ID. Defaults to the default store. |
| profile_schema | string | No | The user profile schema ID. |
| meta_data | object | No | Custom metadata for categorizing memories. |