# Hindsight

来源: https://docs.aicentos.com/clients/hindsight

Language: zh-CN

> 给 Hindsight 记忆服务配 aicentos 的模型 —— 四个环境变量搞定，OpenAI 兼容

Hindsight 是开源的 agent 记忆系统，提供自托管服务、HTTP / MCP 接口、SDK 和 CLI。它自己不是聊天客户端，但**记忆提炼要用一个 LLM**，那个 LLM 可以指向 aicentos。

## 准备工作

先在控制台为 Hindsight 建一个专用 Key（建议命名 `hindsight`）。

* 控制台：[https://aicentos.com](https://aicentos.com)
* 创建 Key：[https://aicentos.com/keys](https://aicentos.com/keys)
* 钱包充值：[https://aicentos.com/wallet](https://aicentos.com/wallet)

Hindsight 服务端需要 PostgreSQL 14 及以上。它自带的 `pg0` 只适合开发，生产环境请接自己的实例。

```bash
pip install hindsight-api
```

## 需要填写的配置

| 环境变量                         | 值                         |
| ---------------------------- | ------------------------- |
| `HINDSIGHT_API_LLM_PROVIDER` | `openai`                  |
| `HINDSIGHT_API_LLM_BASE_URL` | `https://aicentos.com/v1` |
| `HINDSIGHT_API_LLM_API_KEY`  | 控制台创建的 Key                |
| `HINDSIGHT_API_LLM_MODEL`    | 控制台「模型广场」中的模型名            |

## 配置步骤

写进启动环境即可，不需要改代码：

```bash
export HINDSIGHT_API_LLM_PROVIDER="openai"
export HINDSIGHT_API_LLM_BASE_URL="https://aicentos.com/v1"
export HINDSIGHT_API_LLM_API_KEY="sk-你的-API-Key"
export HINDSIGHT_API_LLM_MODEL="你的模型名"

hindsight-api
```

用 Docker 部署时把这些变量放进 compose 的 `environment`。注意官方镜像不含 `llama.cpp`，别指望在容器里跑本地模型。

## 测试

```bash
curl -fsSL https://hindsight.vectorize.io/get-cli | bash
hindsight health
```

服务起来后写入一条记忆、再检索回来，能走通说明 LLM 调用正常。也可以直接看控制台用量：Hindsight 每提炼一次记忆都会产生一条请求。

## 注意事项

* `BASE_URL` 必须以 `/v1` 结尾，且上游要能服务 `/chat/completions`；写成 `https://aicentos.com` 会 404。
* 没配 LLM Key 时服务会拒绝启动，这是它的强制校验，不是 Key 填错。
* 记忆提炼是后台批处理，用量会随记忆条数增长，建议给 Hindsight 单独一个 Key 便于观察。
* `HINDSIGHT_API_LLM_PROVIDER` 填 `openai` 表示走 OpenAI 兼容协议，不是指只能用 OpenAI 模型。

## 相关链接

* [Hindsight 模型配置](https://hindsight.vectorize.io/developer/models)
* [hindsight 仓库](https://github.com/vectorize-io/hindsight)