全部客户端
Pi 使用 api: "anthropic-messages" 与 !printenv BF16_API_KEY 直连 https://api.bf16.ai,密钥无需明文写入 models.json。
极简可编程 CLI · Anthropic 原生流1M Context · ZDR
Pi
原生使用 Anthropic Messages 协议的极简终端编码智能体。
接口地址
https://api.bf16.ai协议
anthropic-messages适用对象
希望在 Pi 中接入百万级上下文免审查模型的开发者。
架构原理与接入优势
Pi 是一款轻量、易扩展的终端编码智能体(同时也被 Rakazo 与 OpenBot 用作底层运行时)。通过 `~/.pi/agent/models.json` 中的 `!printenv BF16_API_KEY` 语法,可在保持配置文件零明文密钥的同时挂载自定义提供商。
将 `baseUrl` 设为 `https://api.bf16.ai`(不带 `/v1`)并选用 `anthropic-messages` 协议,即可完整获得流式思考块签名续传与 1,048,576 上下文窗口。
命令默认显示 $BF16_API_KEY。登录并创建密钥后会自动填入你的真实密钥。
终端一键配置
一键合并写入 Pi `~/.pi/agent/models.json`
自动备份现有 models.json,无损合并 `providers.bf16` 全部百万上下文模型并完成接口验证。
export BF16_API_KEY="sk-bf16-v1-..."
mkdir -p ~/.pi/agent
node -e '
const fs = require("fs"), os = require("os"), path = require("path");
const file = path.join(os.homedir(), ".pi/agent/models.json");
const incoming = JSON.parse("{\n \"providers\": {\n \"bf16\": {\n \"name\": \"bf16.ai\",\n \"baseUrl\": \"https://api.bf16.ai\",\n \"api\": \"anthropic-messages\",\n \"apiKey\": \"!printenv BF16_API_KEY\",\n \"models\": [\n { \"id\": \"zai-org/glm-5.3-uncensored\", \"name\": \"Uncensored GLM-5.3\", \"reasoning\": true, \"contextWindow\": 1048576 },\n { \"id\": \"zai-org/glm-5.3-flash-uncensored\", \"name\": \"Uncensored GLM-5.3 Flash Vision\", \"reasoning\": true, \"input\": [\"text\", \"image\"], \"contextWindow\": 1048576 },\n { \"id\": \"deepseek/deepseek-v4.1-flash-uncensored\", \"name\": \"Uncensored DeepSeek V4.1 Flash\", \"reasoning\": true, \"input\": [\"text\", \"image\"], \"contextWindow\": 1048576 },\n { \"id\": \"deepseek/deepseek-v4.1-flash-uncensored-fast\", \"name\": \"Uncensored DeepSeek V4.1 Flash Fast\", \"reasoning\": true, \"input\": [\"text\", \"image\"], \"contextWindow\": 1048576 },\n { \"id\": \"bf16/deepseek-v4.1-flash-1017-exl3-2.5bpw\", \"name\": \"DeepSeek V4.1 Flash 1017 EXL3 2.5bpw (bf16)\", \"reasoning\": true, \"input\": [\"text\", \"image\"], \"contextWindow\": 524288 },\n { \"id\": \"moonshotai/kimi-k3.1-pro-uncensored\", \"name\": \"Uncensored Kimi K3.1 Pro\", \"reasoning\": true, \"input\": [\"text\", \"image\"], \"contextWindow\": 1048576 }\n ]\n }\n }\n}");
let current = { providers: {} };
if (fs.existsSync(file)) {
fs.copyFileSync(file, file + ".bak");
try { current = JSON.parse(fs.readFileSync(file, "utf8")); } catch {}
}
current.providers = Object.assign({}, current.providers || {}, incoming.providers);
fs.writeFileSync(file, JSON.stringify(current, null, 2) + "\n");
console.log("Updated " + file);
' && curl -fsS "https://api.bf16.ai/v1/models" -H "Authorization: Bearer $BF16_API_KEY" >/dev/null && echo "Ready! Run: pi --model bf16/zai-org/glm-5.3-uncensored"- 1
导出你的 API 密钥
Pi 会从终端环境变量读取 BF16_API_KEY。
export BF16_API_KEY=sk-bf16-v1-... - 2
添加提供商配置
~/.pi/agent/models.json{ "providers": { "bf16": { "name": "bf16.ai", "baseUrl": "https://api.bf16.ai", "api": "anthropic-messages", "apiKey": "!printenv BF16_API_KEY", "models": [ { "id": "zai-org/glm-5.3-uncensored", "name": "Uncensored GLM-5.3", "reasoning": true, "contextWindow": 1048576 }, { "id": "zai-org/glm-5.3-flash-uncensored", "name": "Uncensored GLM-5.3 Flash Vision", "reasoning": true, "input": ["text", "image"], "contextWindow": 1048576 }, { "id": "deepseek/deepseek-v4.1-flash-uncensored", "name": "Uncensored DeepSeek V4.1 Flash", "reasoning": true, "input": ["text", "image"], "contextWindow": 1048576 }, { "id": "deepseek/deepseek-v4.1-flash-uncensored-fast", "name": "Uncensored DeepSeek V4.1 Flash Fast", "reasoning": true, "input": ["text", "image"], "contextWindow": 1048576 }, { "id": "bf16/deepseek-v4.1-flash-1017-exl3-2.5bpw", "name": "DeepSeek V4.1 Flash 1017 EXL3 2.5bpw (bf16)", "reasoning": true, "input": ["text", "image"], "contextWindow": 524288 }, { "id": "moonshotai/kimi-k3.1-pro-uncensored", "name": "Uncensored Kimi K3.1 Pro", "reasoning": true, "input": ["text", "image"], "contextWindow": 1048576 } ] } } } - 3
启动运行
pi --model bf16/zai-org/glm-5.3-uncensored
Pi Coding Agent — ~/.pi/agent/models.json
图形界面与配置字段对照表providers.bf16 · api: "anthropic-messages"
核心参数逐项核对清单
baseUrl
https://api.bf16.aiAnthropic 协议切勿加 /v1 后缀。
apiKey
!printenv BF16_API_KEY运行时动态读取环境变量。
contextWindow
1048576可在 Pi 会话内随时输入 /model 切换模型,或通过 pi --model bf16/zai-org/glm-5.3-uncensored 直接启动。
推荐模型分层调度方案
将复杂架构规划交给旗舰模型,将高频并行子任务、浏览器操作与截图识别分流至高性价比 Flash 模型。
| 任务角色 | 推荐模型 ID | 选型理由 | 每百万 Token 定价 |
|---|---|---|---|
| 主力代码重构与排障 | zai-org/glm-5.3-uncensored | Anthropic 协议下工具块拼装与跨文件编辑最稳健。 | $1.35 输入 / $0.25 缓存 / $4.20 输出 |
| 视觉识图与快速问答 | deepseek/deepseek-v4.1-flash-uncensored | 原生支持 `input: ["text", "image"]` 图片输入与极速流式返回。 | $0.26 输入 / $0.045 缓存 / $1.00 输出 |
如何确认配置成功
- Pi 启动时会列出 bf16 提供商。
- 请求记录会实时出现在控制台日志中。
- curl https://api.bf16.ai/v1/models -H "Authorization: Bearer $BF16_API_KEY"
生产部署安全护栏与预算隔离
- 保持 `"apiKey": "!printenv BF16_API_KEY"` 写法,这样即便备份同步 dotfiles 也不会泄露明文密钥。
常见错误
现象
每次调用都返回 404。
原因
baseUrl 多写了 /v1,Anthropic 协议格式不需要带 /v1。
解法
请使用 https://api.bf16.ai。