SuperAPI AI 工具集

supermemory

智能体与模型

查看项目

更新于 10-16 04:04

技能介绍

Supermemory 是一个面向 AI 智能体的记忆、上下文与 RAG 基础设施 API。当用户提到「Supermemory」「记忆层」「智能体记忆」「上下文基础设施」等概念时,可使用该技能。

一、用途 Supermemory 用于为 AI 智能体提供持久化记忆与上下文检索能力。开发者可以把文本、URL 或文件写入记忆库,再通过语义搜索召回相关内容,作为 LLM 的上下文依据。它同时支持「memory」(默认,完整上下文层)和「superrag」(托管 RAG)两种任务类型。

二、认证与环境变量 所有请求都需要在 Authorization 头中传入 API 密钥: Authorization: Bearer $SUPERMEMORY_API_KEY API 密钥从 console.supermemory.ai → API Keys 创建或复制,密钥以 sm_ 开头。 环境变量:SUPERMEMORY_API_KEY,即 Supermemory API 密钥(以 sm_ 开头)。

三、主要端点 基础 URL:https://api.supermemory.ai

  1. 添加文档/记忆 POST /v3/documents 写入单条文档,内容可以是原始文本、URL 或文件引用。使用 containerTag 将记忆限定到某个用户、项目或智能体。 示例请求体(写入 /tmp/supermemory_add.json): { "content": "I prefer dark mode in all applications.", "containerTag": "user-123", "metadata": { "category": "preferences" } } 执行命令: curl -s -X POST "https://api.supermemory.ai/v3/documents" --header "Authorization: Bearer $SUPERMEMORY_API_KEY" --header "Content-Type: application/json" -d @/tmp/supermemory_add.json 可选字段:customId(自定义稳定标识,用于 upsert/按 id 删除);taskType("memory" 为默认完整上下文层,"superrag" 为托管 RAG);containerTag 接受字母数字、连字符、下划线和点,最长 100 字符。

  2. 批量添加文档 POST /v3/documents/batch 单次请求最多写入 600 条文档。 示例请求体(写入 /tmp/supermemory_batch.json): { "documents": [ { "content": "First memory" }, { "content": "Second memory" } ], "containerTag": "user-123" } 执行命令: curl -s -X POST "https://api.supermemory.ai/v3/documents/batch" --header "Authorization: Bearer $SUPERMEMORY_API_KEY" --header "Content-Type: application/json" -d @/tmp/supermemory_batch.json

  3. 搜索记忆(语义召回) POST /v4/search 在记忆中进行语义搜索。用 containerTag 限定范围,用 threshold(0–1,默认 0.6)调节精度。 示例请求体(写入 /tmp/supermemory_search.json): { "q": "display preferences", "containerTag": "user-123", "threshold": 0.6 } 执行命令: curl -s -X POST "https://api.supermemory.ai/v4/search" --header "Authorization: Bearer $SUPERMEMORY_API_KEY" --header "Content-Type: application/json" -d @/tmp/supermemory_search.json 可选字段:filters(带 AND/OR 逻辑的元数据谓词,最多 5 层嵌套);limit(返回结果上限)。

  4. 列出文档 POST /v3/documents/list 分页列出文档,支持可选过滤。 示例请求体(写入 /tmp/supermemory_list.json): { "containerTags": ["user-123"], "limit": 50 } 执行命令: curl -s -X POST "https://api.supermemory.ai/v3/documents/list" --header "Authorization: Bearer $SUPERMEMORY_API_KEY" --header "Content-Type: application/json" -d @/tmp/supermemory_list.json

  5. 获取单个文档 GET /v3/documents/<document-id> 获取单个文档及其当前处理状态。 curl -s "https://api.supermemory.ai/v3/documents/<document-id>" --header "Authorization: Bearer $SUPERMEMORY_API_KEY"

  6. 更新文档 PATCH /v3/documents/<document-id> 更新内容、元数据或容器归属。 示例请求体(写入 /tmp/supermemory_update.json): { "metadata": { "category": "preferences", "verified": true } } 执行命令: curl -s -X PATCH "https://api.supermemory.ai/v3/documents/<document-id>" --header "Authorization: Bearer $SUPERMEMORY_API_KEY" --header "Content-Type: application/json" -d @/tmp/supermemory_update.json

  7. 删除文档 DELETE /v3/documents/<document-id> curl -s -X DELETE "https://api.supermemory.ai/v3/documents/<document-id>" --header "Authorization: Bearer $SUPERMEMORY_API_KEY"

  8. 上传文件 POST /v3/documents/file 上传文件(PDF、图片、音频等)进行处理,使用 multipart/form-data。 curl -s -X POST "https://api.supermemory.ai/v3/documents/file" --header "Authorization: Bearer $SUPERMEMORY_API_KEY" -F "file=@/path/to/document.pdf" -F "containerTag=user-123"

  9. 连接(外部集成) Supermemory 可从 Notion、Google Drive、Gmail、GitHub、OneDrive 和 S3 拉取内容。连接在仪表盘中管理,但可通过 API 列出和同步。 列出所有连接: curl -s "https://api.supermemory.ai/v3/connections" --header "Authorization: Bearer $SUPERMEMORY_API_KEY" 触发同步: curl -s -X POST "https://api.supermemory.ai/v3/connections/<connection-id>/sync" --header "Authorization: Bearer $SUPERMEMORY_API_KEY"

四、容器标签(作用域) 容器标签是 Supermemory 划分数据的方式,可当作命名空间使用:

  • 按用户:user-123,用于终端用户记忆
  • 按智能体:agent-sales-bot,用于智能体身份
  • 按项目:project-q2-launch,用于工作区/项目记忆
  • 组合:user-123:project-q2,用于交叉范围 标签接受字母数字、-、_ 和 .,最长 100 字符。

五、文档状态生命周期 文档依次经历:queued → extracting → chunking → embedding → indexing → done。只有处于 done 状态的文档才会出现在搜索结果中。

六、注意事项

  • 搜索默认使用语义向量召回;可结合 filters 实现元数据 + 语义的混合查询。
  • customId 支持幂等 upsert——重复提交相同 customId 会更新已有文档。
  • taskType: "superrag" 模式返回适合直接用于 LLM 接地的答案形态响应。
  • 速率限制和存储配额取决于你的 Supermemory 套餐;可在 console.supermemory.ai 查看当前用量。

七、故障排查 如果请求失败,可运行: zero doctor check-connector --env-name SUPERMEMORY_API_KEY 或: zero doctor check-connector --url https://api.supermemory.ai/v3/documents/list --method POST

八、参考链接 文档:https://supermemory.ai/docs API 参考:https://supermemory.ai/docs/api-reference 仪表盘:https://console.supermemory.ai