文档 · 指南

让 Craft Agents 用任意模型

Craft Agents(lukilabs/craft-agents-oss)是一个 Electron 应用,运行 Claude 和 Pi 会话。它的模型来自“连接”,自定义端点也是一种连接。magpie 加一个名为 magpie 的连接,并把它设为新会话的默认连接,于是 Craft Agents 能用你在 magpie 里的任何模型:DeepSeek、GLM、Kimi、Qwen、OpenAI 或 Anthropic Key,或 ChatGPT、Copilot 订阅。

接入 Craft Agents

  1. 先打开一次 Craft AgentsCraft Agents 不会加载没有工作区的 config.json,所以 magpie 从不自己新建这个文件。第一次运行 Craft Agents 后它才会有。
  2. 在 magpie 里添加供应商在 供应商 页添加 API Key,或登录一个订阅。
  3. 在 Craft Agents 那一行选模型在 Agent 页给 Craft Agents 选一个 magpie 模型。Craft Agents 监视 config.json,运行中的应用马上用上,从下一个新会话开始。
终端
magpie craft-agents deepseek/deepseek-v4-pro

magpie 连接

连接写在 Craft Agents 配置目录的 config.json 里(设了 CRAFT_CONFIG_DIR 时用它,否则是 ~/.craft-agent)。magpie 的连接是一个 pi_compat 连接,走 OpenAI 兼容的 Chat Completions;models 是你在 magpie 里为 Craft Agents 选的模型,defaultModel 是你选中的那个。

终端
"llmConnections": [
  …,
  {"slug": "magpie", "name": "magpie", "providerType": "pi_compat",
   "authType": "none",
   "baseUrl": "http://127.0.0.1:3425/agent/craft-agents/v1",
   "customEndpoint": {"api": "openai-completions"},
   "models": [{"id": "deepseek/deepseek-v4-pro", "name": …}, …],
   "defaultModel": "deepseek/deepseek-v4-pro"}
],
"defaultLlmConnection": "magpie"

Craft Agents 会把不在 models 里的 defaultModel 改成列表里的第一个,所以 magpie 总把你选的模型放进列表。你在 Craft Agents 里给这个连接改的名字和其他字段,magpie 同步时会保留。

不用填 Key

Craft Agents 的 Key 不在 config.json 里,而是加密存在 credentials.enc,magpie 不会打开它。magpie 的连接用 authType: none,这正是 Craft Agents 自己为本机无 Key 端点(“Local Model”)保存的写法;它的 Pi 服务会发一个占位 Key,网关接受来自本机的这种请求。Craft Agents 的请求没有自己的 User-Agent,所以地址里的 /agent/craft-agents 告诉网关请求来自哪个 Agent。

新会话和已开的会话

新会话从 defaultLlmConnection 指定的连接开始;工作区自己设了默认连接时,以工作区的为准。已经打开的会话一直用它开始时的连接,所以换到 magpie 后要开一个新会话。magpie 在 Craft Agents 运行时也会提示这一点。

你自己的连接

你的连接和 config.json 里的其他键都按原样保留。magpie 接管默认连接前会记下你原来的默认连接,切回时还原(如果那个连接还在;不在时 Craft Agents 用它的第一个连接)。如果你在 Craft Agents 里删了 magpie 连接,magpie 的检查会提示它已经不再走 magpie。

切回

在 magpie 里把那一行切回默认,magpie 拿掉它的连接,并还原你原来的默认连接。也可以直接选你自己连接里的模型,magpie 会把它设为那个连接的默认模型。

终端
magpie craft-agents default

常见问题

Craft Agents 能用 DeepSeek、GLM、Kimi 或 Qwen 吗?

能。magpie 在 Craft Agents 的 config.json 里加一个 magpie 连接,并把它设为新会话的默认连接,你在 magpie 里的模型都在这个连接里。

需要在 Craft Agents 里填 API Key 吗?

不需要。magpie 的连接用 authType none,和 Craft Agents 为本机无 Key 端点保存的方式一样,网关接受来自本机的请求。

为什么切换后还在用原来的模型?

已经打开的会话一直用它开始时的连接。开一个新会话;如果工作区自己设了默认连接,那个设置优先。

magpie 提示要先打开 Craft Agents?

Craft Agents 不会加载没有工作区的 config.json,所以 magpie 不会自己新建这个文件。先运行一次 Craft Agents 再接入。

更多 Agent 用同样的模型:Claude Code 接入其他模型、让 T3 Code 用任意模型、让 CodeBuddy 用任意模型。遇到报错?见 常见错误排查,或到 Discord 提问。