CreateMemory
Creates a long-term memory.
Operation description
-
You can store specific information from conversations (memory nodes, see Long-term memory) in a long-term memory (Memory). Agent applications can then reference this information in subsequent conversations. This is not an automatic process. You must first invoke the CreateMemory operation to create a long-term memory and obtain the memoryId. Then, pass the memoryId when you invoke the agent application through the API.
Note Long-term memory does not yet support storing or managing user profiles. Perform related operations in the console. For more information, see Long-term memory.
-
If you pass a memoryId, the system automatically creates memory nodes (MemoryNode) under the specified long-term memory based on conversation records. You can also invoke the CreateMemoryNode operation to manually create memory nodes.
-
This operation does not support idempotency.
Throttling: Ensure that the interval between two consecutive requests is at least 1 second. Otherwise, throttling may be triggered. If throttling occurs, retry later.
Try it now
You can run this API directly in OpenAPI Explorer, which saves you the trouble of calculating signatures. After the call succeeds, OpenAPI Explorer can automatically generate SDK code examples.
Authorization information
The following table describes the authorization information of the API. You can use the action in the Action element of a RAM policy statement to grant RAM users or RAM roles the permission to call this API. For more information, see the following:
-
Action: the specific permission.
-
Access level: the access level of each operation. Valid values: Write, Read, and List.
-
Resource type: the resource types that support authorization in the operation. For more information, see the following:
- Required resource types are marked with an asterisk (*) prefix.
- For operations that do not support resource-level authorization,
All Resourcesis used.
-
Condition key: the condition keys defined by the cloud service.
-
Dependent action: other permissions required to successfully perform the operation. The caller must have the permissions of all dependent actions for the operation to succeed.
| Action | Access level | Resource type | Condition key | Dependent action |
|---|---|---|---|---|
| sfm:CreateMemory | create | *All Resources * |
| None |
Request syntax
POST /{workspaceId}/memories HTTP/1.1
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| workspaceId | string | Yes | The ID of the workspace to which the long-term memory belongs. For information about how to obtain the workspace ID, see How to use workspaces. | llm-3z7uw7fwz0vexxxx |
| description | string | No | The description of the long-term memory. The description must be 1~50 characters in length and can contain characters in the Unicode letter category (including English letters, Chinese characters, and digits). The description can contain colons (:), underscores (_), periods (.), and hyphens (-). | The long-term memory of my LLM application $APP_ID about user A |
Response elements
| Element | Type | Description | Example |
|---|---|---|---|
| object | Schema of Response | ||
| memoryId | string | The ID of the long-term memory. Note Store this value properly. It will be used in all subsequent API operations related to this long-term memory. | 6bff4f317a14442fbc9f73d29dbxxxx |
| requestId | string | The request ID. | 17204B98-xxxx-4F9A--2446A84821CA |
Examples
Success response
JSON format
{
"memoryId": "6bff4f317a14442fbc9f73d29dbxxxx",
"requestId": "17204B98-xxxx-4F9A--2446A84821CA"
}
Error codes
| HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 400 | Memory.DescriptionInvalid | Input parameter description is invalid. | The description of the memory is invalid |
| 404 | Memory.MemoryIdNotFound | Memory Id not exist or is not authorized. | memoryId not found |
| 500 | Memory.InternalError | Memory service inner exception. | Memory service internal exception. |
See Error Center for more error codes.