HTTP API

所有端点,一个基础 URL。

无需 SDK - 任何 HTTP 客户端都可用。基础 URL 为 https://api.wontopos.com,通过 X-API-Key 请求头认证,请求与响应均为 JSON。记忆操作均为 POST;存储库管理使用 /collection 上的 POST / GET / DELETE。存储库必须先存在(见存储库),否则库内操作返回 404

请求头

请求头作用
X-API-Key每次调用都必需。您的密钥,在控制台签发。
X-WOS-Model可选。选择由哪个引擎作答。省略则使用账户的默认值。GET /api/v1/models 会列出您的密钥可以选择的模型;更早的引擎无法提供的端点会返回 501,并指出是哪个模型。
Idempotency-Key写入时可选。同一密钥配同一请求体时不会重复存储,而是重放首次响应 - 见下面的说明。

端点

端点用途请求体字段
POST /api/v1/memory/collection创建存储库user_id
GET /api/v1/memory/collections列出您的存储库(无)
DELETE /api/v1/memory/collection删除存储库及其全部记忆user_id
/api/v1/memory/store存储一条记忆user_id · content · metadata? (event_date · speaker) · image?
/api/v1/memory/store-turn存储一轮对话user_id · user_msg · assistant_msg
POST /api/v1/memory/speakers注册说话者(显式,最多 50 人)user_id · speaker
GET /api/v1/memory/speakers列出已注册说话者 + 记忆数user_id
DELETE /api/v1/memory/speakers注销说话者(记忆保留)user_id · speaker
/api/v1/memory/by-speaker某个人说过的话,从最新开始(“me” = 智能体自己)user_id · speaker · limit? · before? · skip_ids?
POST /api/v1/memory/image图像记忆中我们保存的那张图(不是原图)user_id · memory_id
DELETE /api/v1/memory/image删除图像,保留文字user_id · memory_id · preview?
/api/v1/memory/images某个存储的图像,从最新开始(+ 总数)user_id · limit? · before? · skip_ids?
/api/v1/memory/lineage一条记忆的修改链,从最早开始user_id · memory_id
GET /api/v1/won/usage此密钥的花费与剩余余额 — 供模型判断是否继续。免费。days?
GET /api/v1/memory/usage此密钥的花费与剩余余额 — 供模型判断是否继续。免费。days?
/api/v1/won/revisions某个存储被改写了多少。免费user_id · include? · limit? · before? · skip_ids?
/api/v1/memory/revisions同一调用在 memory 平面下的名字。免费user_id · include? · limit? · before? · skip_ids?
/api/v1/memory/bulk-store回填一段文本user_id · content · category? · timestamp?
/api/v1/memory/search语义搜索user_id · query · max_results? · speaker? · cache_control? · filters? · verify? · max_images?
/api/v1/memory/recall短期 + 长期 + 上下文user_id · query · limit? · context_limit?
/api/v1/memory/get按 id 取单条记忆user_id · memory_id
/api/v1/memory/list分页浏览存储user_id · limit? · cursor?
/api/v1/memory/history最近的对话轮次user_id
/api/v1/memory/stats记忆条数统计user_id
/api/v1/memory/supersede替换已变更的事实user_id · old_memory_id · new_content
/api/v1/memory/forget删除一条(或全部)user_id · memory_id? (省略 = 全部删除)
GET /api/v1/engram该模型可运行的 engram(无)
POST /api/v1/engram/run运行一个 engramname · user_id · query · form? · tz?
GET /api/v1/models可用模型(无)
写入请求接受 Idempotency-Key 头。同一密钥配同一请求体时不会重复存储,而是重放首次响应(10 分钟);同一密钥配不同请求体则返回 422。仅缓存 2xx,因此失败的调用可以立即重试。
# create the store once (stores are explicit)
curl -X POST https://api.wontopos.com/api/v1/memory/collection \
  -H "X-API-Key: $WOS_API_KEY" -H "Content-Type: application/json" \
  -d '{"user_id":"alice"}'

# store a memory
curl -X POST https://api.wontopos.com/api/v1/memory/store \
  -H "X-API-Key: $WOS_API_KEY" -H "Content-Type: application/json" \
  -d '{"user_id":"alice","content":"she prefers tea over coffee"}'

# recall - one call, ready for your prompt
curl -X POST https://api.wontopos.com/api/v1/memory/recall \
  -H "X-API-Key: $WOS_API_KEY" -H "Content-Type: application/json" \
  -d '{"user_id":"alice","query":"what does alice drink?"}'
真实响应 - store
{"id": "576700aa-f0e0-4c26-99a0-10e2d5b0d624", "status": "stored (1 chunks)"}