快速上手

5 分钟完成您的第一次召回。

一个密钥、一行安装命令、三次调用 - 您的智能体就有了记忆。本页每个代码片段都实际运行过;响应原样展示。

1

获取 API 密钥

控制台创建。以 wos-live- 开头的 155 字符密钥只显示一次。请保存在环境变量中 - 绝不要写进代码。

2

安装

pip install wontopos        # Python
npm install wontopos        # TypeScript / JavaScript
cargo add wontopos          # Rust
# curl - nothing to install, just set WOS_API_KEY
# latest: SDK v2.2.37 · MCP v1.0.19
3

创建存储库,然后存储与召回

存储库(store)就是您读写所依据的 user_id。存储库是显式的:先创建(下面的调用),再在其下存储和召回。存储 - 写入时即完成索引,不调用 LLM。召回 - 一次往返返回短期 + 长期 + 上下文。

from wontopos import Client

mem = Client(api_key="wos-live-...", user_id="alice")  # set the store once
mem.create_store()              # create it (stores are explicit)
mem.add("she prefers tea over coffee")  # no user_id needed

# one call → short-term + long-term + context
ctx = mem.recall("what does alice drink?")
import { Client } from "wontopos";

const mem = new Client({ apiKey: "wos-live-...", userId: "alice" });  // set the store once
await mem.createStore();            // create it (stores are explicit)
await mem.add("she prefers tea over coffee");  // no userId needed

// one call → short-term + long-term + context
const ctx = await mem.recall("what does alice drink?");
use wontopos::Client;

let mem = Client::new("wos-live-...").with_user("alice");  // set the store once
mem.create_store(None).await?;            // create it (stores are explicit)
mem.add("she prefers tea over coffee", None, json!({})).await?;

// one call → short-term + long-term + context
let ctx = mem.recall("what does alice drink?", None).await?;
# 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 - indexed on the way in, no LLM call
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"}'

# one call → short-term + long-term + context
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?"}'
真实响应 - create_store()
{"user_id": "alice", "status": "created"}
真实响应 - add()
{"id": "576700aa-f0e0-4c26-99a0-10e2d5b0d624", "status": "stored (1 chunks)"}
只需设置一次存储库。user_id 传给客户端后,每个调用都会使用它 - 无需重复;给单个调用传入 user_id 即可覆盖。存储库是显式的:向不存在的存储库写入或从中召回会返回 404 - 请先创建。每个账户自带一个 default 存储库,因此完全不传 user_id 的零配置路径也能直接工作。列出与管理存储库见存储库

recall() 返回四个块 - short_term(最近的对话轮次)、long_term(相关记忆)、context(最佳匹配的前后文),以及一条告诉 LLM 如何使用它们的 instruction。整体放入您的提示词即可。

任何语言都适用。用英语存储,用韩语、日语或中文提问 - 都能召回同一条记忆。70 个语言配对上 recall@5 95.2%。

各语言的全部方法 →

同一客户端,不同设置

mem = Client.from_env()                 # reads WONTOPOS_API_KEY
scroll = mem.with_model("scroll-1.2")  # this copy only: another engine
alice  = mem.with_user("alice")       # this copy only: another default store
const alice = mem.withUser("alice");
const scroll = mem.withModel("scroll-1.2");
let alice = mem.with_user("alice");
let scroll = mem.with_model("scroll-1.2");
# curl has no copies — send model and user_id with each request
curl ... -d '{"user_id":"alice","model":"scroll-1.2","query":"…"}'