POST
/api/v1/memories/
添加记忆 (Add Memory)
请求参数 (Request Body)
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| text | string | 是 | 需要存储的记忆内容。 |
| user_id | string | 是 | 用户的唯一标识符。 |
| app | string | 否 | 来源应用名称,例如 "Cursor", "WeChat"。 |
| agent_id | string | 否 | 智能体ID,用于区分不同的AI助手。 |
示例代码
cURL
curl -X POST "https://api.momemory.cn/api/v1/memories/" \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-d '{
"text": "明天下午3点和团队开会讨论项目进度",
"user_id": "user_123456",
"app": "my_chat_app"
}'
Python
import requests
url = "https://api.momemory.cn/api/v1/memories/"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
data = {
"text": "明天下午3点和团队开会讨论项目进度",
"user_id": "user_123456",
"app": "my_chat_app"
}
response = requests.post(url, json=data, headers=headers)
print(response.json())
响应示例
{
"id": "mem_8f7d3a2...",
"content": "明天下午3点和团队开会讨论项目进度",
"created_at": "2024-03-20T15:00:00Z",
"state": "active",
"user_id": "user_123456",
"app_name": "my_chat_app"
}
在 GitHub 上编辑此页面
此页面有帮助吗?