SwarmRecall Knowledge
Knowledge graph with entities, relations, traversal, and semantic search via the SwarmRecall API.
Auto-Registration
Before making any API calls, check for a SWARMRECALL_API_KEY environment variable:
- 1. If
SWARMRECALL_API_KEY is set, use it for all requests as a Bearer token. - If
SWARMRECALL_API_KEY is not set, self-register by calling:
POST https://swarmrecall-api.onrender.com/api/v1/register
Content-Type: application/json
{ "name": "<your-agent-name>" }
- 3. The response returns
{ "apiKey": "...", "claimToken": "..." }. Save the apiKey to the SWARMRECALL_API_KEY environment variable for all subsequent requests. Do NOT write the key to disk or any file without user consent. - Tell the user: "SwarmRecall is set up! To manage your agent's data, visit swarmrecall.ai/claim with code:
<claimToken>"
Authentication
All API requests require:
CODEBLOCK1
API Base URL
INLINECODE7 (override with SWARMRECALL_API_URL if set)
All endpoints below are prefixed with /api/v1.
Privacy & Data Handling
- - All data is sent to
swarmrecall-api.onrender.com over HTTPS - Knowledge graph data (entities, relations) is stored server-side with vector embeddings for semantic search
- Data is isolated per agent and owner — no cross-tenant access
- Before storing user-provided content, ensure the user has consented to external storage
- The
SWARMRECALL_API_KEY should be stored as an environment variable only, not written to disk
Endpoints
Create an entity
CODEBLOCK2
Get an entity
CODEBLOCK3
List entities
CODEBLOCK4
Update an entity
CODEBLOCK5
Delete an entity
CODEBLOCK6
Create a relation
CODEBLOCK7
List relations
CODEBLOCK8
Delete a relation
CODEBLOCK9
Traverse the graph
CODEBLOCK10
Search entities
CODEBLOCK11
Validate the graph
CODEBLOCK12
Behavior
- - When the user provides structured information: create entities with
POST /api/v1/knowledge/entities. - When linking concepts: create relations with
POST /api/v1/knowledge/relations. - When the user asks "what do I know about X?": search with
GET /api/v1/knowledge/search?q=X, then traverse with GET /api/v1/knowledge/traverse to explore connections. - Periodically: call
POST /api/v1/knowledge/validate to check graph constraints.
Shared Pools
- - The
POST /api/v1/knowledge/entities and POST /api/v1/knowledge/relations endpoints accept an optional "poolId" field. - When
poolId is provided, the entity or relation is shared with all pool members who have knowledge read access. - The agent must have readwrite access to the pool's knowledge module to write shared entities and relations.
- Search (
GET /api/v1/knowledge/search) and list (GET /api/v1/knowledge/entities, GET /api/v1/knowledge/relations) results automatically include data from pools the agent belongs to. - Pool data in responses includes
poolId and poolName fields to distinguish shared data from the agent's own data.
Dreaming Integration
Knowledge entities and relations are affected by dream operations:
- - Duplicate entities: Entity pairs of the same type with similar names/embeddings are identified. The agent reviews each pair and decides: merge, keep both, or archive one. For merges, migrate relations from the archived entity to the survivor before archiving.
- Orphan cleanup: Relations pointing to archived entities are automatically removed by Tier 1 dream operations (no agent action needed).
- Knowledge graph enrichment: During dreaming, the agent can read recent memories and extract new entities and relations, creating them via
POST /api/v1/knowledge/entities and POST /api/v1/knowledge/relations.
SwarmRecall 知识库
通过 SwarmRecall API 实现包含实体、关系、遍历和语义搜索的知识图谱。
自动注册
在进行任何 API 调用之前,检查是否存在 SWARMRECALLAPIKEY 环境变量:
- 1. 如果已设置 SWARMRECALLAPIKEY,则在所有请求中将其作为 Bearer 令牌使用。
- 如果未设置 SWARMRECALLAPIKEY,通过以下方式自行注册:
POST https://swarmrecall-api.onrender.com/api/v1/register
Content-Type: application/json
{ name: }
- 3. 响应返回 { apiKey: ..., claimToken: ... }。将 apiKey 保存到 SWARMRECALLAPIKEY 环境变量中,用于所有后续请求。未经用户同意,不得将密钥写入磁盘或任何文件。
- 告知用户:SwarmRecall 已设置完成!要管理您的代理数据,请访问 swarmrecall.ai/claim,使用代码:
身份验证
所有 API 请求都需要:
Authorization: Bearer APIKEY>
API 基础 URL
https://swarmrecall-api.onrender.com(如果设置了 SWARMRECALLAPIURL,则覆盖该值)
以下所有端点均以 /api/v1 为前缀。
隐私与数据处理
- - 所有数据通过 HTTPS 发送至 swarmrecall-api.onrender.com
- 知识图谱数据(实体、关系)存储在服务器端,并包含用于语义搜索的向量嵌入
- 数据按代理和所有者隔离——无跨租户访问
- 在存储用户提供的内容之前,确保用户已同意外部存储
- SWARMRECALLAPIKEY 仅应作为环境变量存储,不得写入磁盘
端点
创建实体
POST /api/v1/knowledge/entities
{
type: person,
name: Alice,
properties: { role: engineer },
poolId: // 可选——写入共享池
}
获取实体
GET /api/v1/knowledge/entities/:id
列出实体
GET /api/v1/knowledge/entities?type=person&limit=20&offset=0&includeArchived=false
更新实体
PATCH /api/v1/knowledge/entities/:id
{ name: Alice Smith, properties: { role: senior engineer } }
删除实体
DELETE /api/v1/knowledge/entities/:id
创建关系
POST /api/v1/knowledge/relations
{
fromEntityId: ,
toEntityId: ,
relation: works_on,
properties: {},
poolId: // 可选——写入共享池
}
列出关系
GET /api/v1/knowledge/relations?entityId=&relation=works_on&limit=20&offset=0
删除关系
DELETE /api/v1/knowledge/relations/:id
遍历图谱
GET /api/v1/knowledge/traverse?startId=&relation=works_on&depth=2&limit=50
搜索实体
GET /api/v1/knowledge/search?q=&limit=10&minScore=0.5
验证图谱
POST /api/v1/knowledge/validate
行为
- - 当用户提供结构化信息时:使用 POST /api/v1/knowledge/entities 创建实体。
- 当连接概念时:使用 POST /api/v1/knowledge/relations 创建关系。
- 当用户询问关于 X 我知道什么?时:使用 GET /api/v1/knowledge/search?q=X 进行搜索,然后使用 GET /api/v1/knowledge/traverse 遍历以探索连接。
- 定期:调用 POST /api/v1/knowledge/validate 检查图谱约束。
共享池
- - POST /api/v1/knowledge/entities 和 POST /api/v1/knowledge/relations 端点接受可选的 poolId 字段。
- 当提供 poolId 时,该实体或关系将与所有具有知识读取权限的池成员共享。
- 代理必须对池的知识模块具有读写权限,才能写入共享实体和关系。
- 搜索(GET /api/v1/knowledge/search)和列表(GET /api/v1/knowledge/entities、GET /api/v1/knowledge/relations)结果自动包含代理所属池中的数据。
- 响应中的池数据包含 poolId 和 poolName 字段,用于区分共享数据与代理自身数据。
梦境集成
知识实体和关系受梦境操作影响:
- - 重复实体:识别出相同类型且名称/嵌入相似的实体对。代理审查每对并决定:合并、保留两者或归档其中一个。对于合并操作,在归档前将关系从归档实体迁移到保留实体。
- 孤立清理:指向已归档实体的关系由一级梦境操作自动移除(无需代理操作)。
- 知识图谱丰富:在梦境期间,代理可以读取最近的记忆并提取新的实体和关系,通过 POST /api/v1/knowledge/entities 和 POST /api/v1/knowledge/relations 创建它们。