简短回答
在 Open Interpreter 中使用 APIVAI:在 ~/.openinterpreter/config.toml 里添加一个自定义提供方,设置 base_url = "https://api.apivai.com/v1"、wire_api = "chat" 和 env_key = "APIVAI_API_KEY",把 model_provider 指向它,并加上 harness = "" 让 Claude 模型保持通用 chat 模式,把 APIVAI 密钥放进环境变量 APIVAI_API_KEY,然后运行 interpreter。Open Interpreter 会自己在基础地址后面加上 chat/completions,所以地址以 /v1 结尾,而且这一个提供方就能运行 Claude 和 GPT 模型,例如 claude-sonnet-4-6 或 gpt-5.5。经典 Python 版则改用 --api_base https://api.apivai.com/v1,并在模型名前加 openai/ 前缀。截至 2026-10-10,通过 APIVAI 使用 Claude Sonnet 4.6 每百万输入 / 输出 token 为 $1.15 / $5.74,官方价为 $3.00 / $15.00,按 token 从预付余额扣费。
2026 年的 Open Interpreter 是什么?
Open Interpreter 是一个开源 Agent,运行在你自己的电脑上:它会读取项目、修改文件并运行命令。这个项目在 2026 年变化很大。当前版本是一个用 Rust 编写的终端 Agent,从 OpenAI 的 Codex CLI 分叉而来,用 interpreter(或 i)启动,用 TOML 配置。它已经不再使用 LiteLLM,所以旧的 --api_base 等参数在新版中不存在。原来的 Python 版(基于 LiteLLM,使用 --api_base 和 YAML 配置档)以 PyPI 上的 open-interpreter 包(最后一个版本 0.4.3)和一个社区维护的分支继续存在。
本文已于 2026 年 10 月对照 Open Interpreter 0.0.56(2026 年 10 月 7 日发布)的文档和源码核实,并在该版本上用 APIVAI 密钥实际测试过。Open Interpreter 本身不带模型;APIVAI 提供一个可调用 Claude 和 GPT 的密钥,按 token 从预付余额扣费。
应该用哪种提供方设置?
| 方式 | base_url | wire_api | 模型 |
|---|---|---|---|
OpenAI 兼容 Chat Completions(推荐),加 harness = "" | https://api.apivai.com/v1 | chat | Claude 和 GPT |
| Anthropic Messages(可选) | https://api.apivai.com | messages | 仅 Claude |
| 经典 Python 版 | --api_base https://api.apivai.com/v1 | 模型前缀 openai/ | Claude 和 GPT |
Open Interpreter 会把 base_url 和请求路径拼接起来。源码中,chat 传输方式追加 chat/completions,Messages 传输方式追加 v1/messages。所以 chat 的 base_url 以 /v1 结尾,而 Messages 的不带。/v1 写错会返回 404。
选 chat 方式:一个提供方覆盖所有模型,并设置 harness = ""(见第 3 步),避免 Claude 模型切换到在这条路上会失败的 claude-code harness。如果想让 Claude 使用这个 harness,请用下文的 Messages 方式。格式说明见 OpenAI 兼容 API 页面。
如何一步步把 Open Interpreter 接入 APIVAI?
第 1 步:创建 APIVAI 密钥
- 在 apivai.com 用邮箱注册。
- 充值:银行卡或加密货币 $10 起,支付宝 / 微信支付 ¥20 起。没有免费试用,也没有订阅。
- 在控制台创建密钥并复制。如果想严格限制 Agent 的花费,可以给密钥设置预算上限。
第 2 步:安装 Open Interpreter
macOS 或 Linux:
curl -fsSL https://www.openinterpreter.com/install | sh
Windows PowerShell:
irm https://www.openinterpreter.com/install.ps1 | iex
重启终端,用 interpreter --version 检查安装结果。这个版本不需要 Python。
第 3 步:把 APIVAI 添加为提供方
创建或编辑 ~/.openinterpreter/config.toml(Windows 上是 %USERPROFILE%\.openinterpreter\config.toml):
model_provider = "apivai" model = "claude-sonnet-4-6" model_context_window = 200000 harness = "" [model_providers.apivai] name = "APIVAI" base_url = "https://api.apivai.com/v1" env_key = "APIVAI_API_KEY" wire_api = "chat"
| 键 | 值 |
|---|---|
model_provider | apivai(提供方表的 id) |
env_key | 存放密钥的环境变量名 |
model_context_window | 可选;200000 是一个保守值 |
harness | ""(不用 harness:所有模型都走通用 chat 模式) |
如果不写 harness = "",Open Interpreter 会把 Claude 模型 ID 切换到 claude-code harness,而它在 0.0.56 中不能走 chat 方式,会报 “compatibility transport” 错误并停止。空值让所有模型都保持通用 chat 模式。
Open Interpreter 可能没有自定义提供方模型的元数据,所以用 model_context_window 告诉它在压缩对话之前可以使用多少上下文;较小的窗口能让每次请求更便宜。
第 4 步:设置密钥
export APIVAI_API_KEY="YOUR_APIVAI_KEY"
在 Windows 上运行 setx APIVAI_API_KEY "YOUR_APIVAI_KEY" 后打开一个新终端,或者在当前 PowerShell 会话中使用 $env:APIVAI_API_KEY = "YOUR_APIVAI_KEY"。不要把密钥写进 config.toml。
第 5 步:开始会话并切换模型
在项目目录中运行 interpreter;/debug-config 会显示当前的提供方和模型。切换模型的方式有:单次运行用 interpreter -m gpt-5.5,会话中用 /model(列表来自 APIVAI 的 GET /v1/models),或者使用配置档。配置档是放在 config.toml 旁边的单独文件,命名为 <name>.config.toml,其中的键会叠加在 config.toml 之上:
# ~/.openinterpreter/gpt.config.toml model = "gpt-5.5"
# ~/.openinterpreter/cheap.config.toml model = "claude-haiku-4-5"
用 interpreter --profile gpt(或 -p gpt)启动配置档。不要在 config.toml 里写 profiles.* 表:那是旧格式,在 0.0.56 中会导致 --profile 报错。模型会随时间上新或下线,请从 GET /v1/models 或价格页复制 ID。
Open Interpreter 会在你的电脑上执行真实的命令。默认情况下它在沙箱中工作(sandbox_mode = "workspace-write"),需要更多权限的操作会先询问你(approval_policy = "on-request")。--yolo 会同时关闭这两项,只应在一次性的虚拟机或容器中使用。
如何为 Claude 使用 Anthropic Messages 方式?
如果你只用 Claude、想用它的原生格式,或者想用 Claude Code harness,可以再添加一个提供方。我们用 APIVAI 密钥实测过这种方式,可以正常工作;Open Interpreter 会自动为它选择 claude-code harness。
[model_providers.apivai-claude]
name = "APIVAI Claude"
base_url = "https://api.apivai.com"
env_key = "APIVAI_API_KEY"
wire_api = "messages"
http_headers = { "anthropic-version" = "2023-06-01" }然后设置 model_provider = "apivai-claude",并删掉 harness = ""(或改成 harness = "claude-code"):Messages 方式必须使用 Claude Code harness,不接受通用模式。不要加 /v1:Open Interpreter 会把 Messages 请求发到 base_url 加 v1/messages。它只会为内置的 Anthropic 提供方自动添加 anthropic-version 请求头,所以要在 http_headers 中设置。GPT 模型不能走这条路。格式说明见 Claude API 代理页面。
如何配置经典 Python 版 Open Interpreter?
经典版用 pip install open-interpreter 安装(Python 3.9 或更高),社区分支用 pip install git+https://github.com/endolith/open-interpreter.git 安装(Python 3.10 或更高)。它通过 LiteLLM 调用模型:
interpreter --api_base https://api.apivai.com/v1 --api_key YOUR_APIVAI_KEY --model openai/claude-sonnet-4-6 --context_window 200000 --max_tokens 8192
openai/ 前缀告诉 LiteLLM 对任何模型 ID 都走 OpenAI 兼容方式。Python 中这样写:
from interpreter import interpreter interpreter.llm.model = "openai/gpt-5.5" interpreter.llm.api_base = "https://api.apivai.com/v1" interpreter.llm.api_key = "YOUR_APIVAI_KEY" interpreter.llm.context_window = 200000 interpreter.llm.max_tokens = 8192 interpreter.chat()
想永久保存设置,运行 interpreter --profiles,打开 default.yaml,在 llm: 部分填写 model、api_base、api_key、context_window 和 max_tokens。经典版在运行每段代码前都会询问;-y(或 auto_run: True)会跳过询问,请谨慎使用。
该选哪个模型?
每百万输入 / 输出 token 价格,截至 2026-10-10:
| 模型 ID | 价格(输入 / 输出) | 适合 |
|---|---|---|
claude-sonnet-5-5 | $0.77 / $3.82 | 编程会话的可靠默认选择 |
claude-sonnet-4-6 | $1.15 / $5.74 | 最受欢迎,支持最广泛 |
claude-opus-5-5 | $1.54 / $7.65 | 最难的任务 |
claude-haiku-4-5 | $0.38 / $1.92 | 快速便宜的脚本和问答 |
gpt-5.5 | $0.77 / $4.56 | GPT 方案 |
gpt-6-sol | $0.30 / $1.52 | 更新的 GPT 模型 |
gpt-6-luna | $0.0144 / $0.0768 | 非常便宜的运行 |
Open Interpreter 依靠工具调用来修改文件和运行命令;上表中的模型通过 APIVAI 都支持工具调用。
Open Interpreter 配合 APIVAI 要花多少钱?
每一轮都会重新发送对话、工具输出和 harness 提示词,所以输入 token 占费用的大头。两个计算示例:
- 一次工作会话,使用 Claude Sonnet 4.6:约 30 次请求,每次约 30,000 输入和 1,500 输出 token。费用:APIVAI $1.29,官方价 $3.38。
- 一个月,每天两次这样的会话,共 22 天(1,320 次请求):APIVAI $56.91,官方价 $149。同样的会话换成 GPT-6 Luna,费用为 $0.0164。
思考 token 按输出 token 计费。每次请求的真实数据都在控制台里。更全面的对比见 2026 年 Claude API 价格对比。
常见报错怎么解决?
- “non-Responses wire APIs require the compatibility transport”: Open Interpreter 在 chat 方式下为 Claude 模型选择了
claude-codeharness。在config.toml中加上harness = "",或者让 Claude 走 Messages 提供方。--chat-completions解决不了这个问题。 - “--profile
gptcannot be used while config.toml contains legacy ...”: 把这个表里的键移到~/.openinterpreter/gpt.config.toml,并从config.toml中删除该表。 - 401 Unauthorized: 密钥错误或已删除,或者启动
interpreter的终端里没有设置APIVAI_API_KEY(用setx设置后要打开新窗口)。 - 402 insufficient_quota: 密钥的预算已用完,或对所选模型来说太低。在控制台给密钥增加预算(Opus 级模型请留出几美元余量),或者换一个更便宜的模型。密钥上剩下的钱不会浪费:删除密钥后会退回账户余额。
- 404 Not Found:
/v1写错了。wire_api = "chat"时base_url是https://api.apivai.com/v1;wire_api = "messages"时是https://api.apivai.com。不要把/chat/completions写进地址。 - 找不到模型: 使用准确的 ID,例如
claude-sonnet-4-6,并用GET /v1/models核对。当前版本不需要openai/前缀。在经典版中,缺少openai/前缀会让 LiteLLM 报错 "LLM Provider NOT provided",或者把请求发到错误的 API。 - 上下文窗口警告或过早压缩: 设置
model_context_window(当前版本),或--context_window和--max_tokens(经典版)。 - 回复为空或被截断: 思考默认开启并消耗输出 token。经典版把
--max_tokens提高到 8192(至少 4096)。当前版本自己设定输出上限,没有 max tokens 选项;对支持的模型,调低model_reasoning_effort(例如"medium")可以给回答留出更多空间。 - 429 Too Many Requests: 每个密钥默认每分钟 60 次请求。稍等片刻,或联系客服提高限额。
请求格式的更多说明见文档。所有 API 错误码及解决方法见 Claude API 错误码大全。
常见问题
Open Interpreter 还有 --api_base 参数吗?
只有经典 Python 版有。当前的 Rust 版在 config.toml 中通过 base_url 和 wire_api 配置提供方。
在 Open Interpreter 中能用一个密钥同时使用 Claude 和 GPT 吗?
可以。一个 APIVAI 密钥适用于所有模型,chat 提供方覆盖两个系列。用 -m、/model 或配置档切换。
Open Interpreter 为什么提示 “non-Responses wire APIs require the compatibility transport”?
它把 Claude 模型切换到了 claude-code harness,而这个 harness 在 0.0.56 中不能走 chat 方式。在 config.toml 中加上 harness = "",或者让 Claude 走 Anthropic Messages 提供方。
APIVAI 会保存我的数据吗?
不会。请求和响应的内容不会被记录,只保留模型、token 数和费用等用于计费的使用数据。
还有类似的终端 Agent 教程吗?
有。请看 Goose 配置教程和 Aider 配置教程。
注册账号,充值 $10 起,把密钥粘贴到 Open Interpreter 即可。