手动设置 Codex

自己动手让 Codex 使用 bInference 并连接 Binance。同样适用于 Codex 和 ChatGPT 桌面应用。

快捷方式

npx binference agent-os my-agent --app codex 会在一个文件夹中设置好这里的一切,并带上交易限制、提醒和驾驶舱。参见设置 Agent。本页介绍如何手动设置 Codex,没有驾驶舱的限制和刹车。

安装 Codex

如果 codex 已经能在你的终端里运行,跳过这一步。

curl -fsSL https://chatgpt.com/codex/install.sh | sh

获取 bInference 密钥

在 binference.io 点击创建密钥,并设置每日消费上限。把密钥存在环境变量里:

export BINF_API_KEY="binf_..."

让 Codex 使用 bInference

Codex 使用 Responses 格式。把 bInference 添加为模型提供方:

~/.codex/config.toml
model_provider = "binference"
model = "openai/gpt-6.1-sol"
web_search = "disabled"

[model_providers.binference]
name = "bInference"
base_url = "https://binference.io/api/v1"
env_key = "BINF_API_KEY"
wire_api = "responses"

模型页面中的任何模型都可以作为 model。这里不提供 Codex 内置的图片工具:bInference 会把它从每个请求中去掉,其他功能照常使用。Codex 还会在每次调用中提供联网搜索,而且不限制一次调用能搜索多少次,所以 bInference 必须在调用开始前预留多轮搜索的费用(即使是小模型也超过 $10)。web_search = "disabled" 能让每次调用的预留保持很小;如果额度充足,你也可以保持开启。

添加 Binance MCP Server

原样运行 Binance 提供的命令,浏览器打开后完成身份验证:

codex mcp add binance-mcp-server --url https://agent.binance.com/mcp/agentic --oauth-client-id codex

只授予你需要的最少权限范围:市场数据、账户、交易或转账。没有提现权限。Codex 和 ChatGPT 桌面应用会使用同一个连接。

检查连接,然后为子账户充值

问 Codex:

Use the Binance MCP Server to show the current BTCUSDT price and 24-hour change.

然后在 binance.com 上转入交易资金:Profile → Dashboard → Sub-account → Asset Management → Transfer。只有你能给 Agentic 子账户充值,而且它一开始是空的。

须知

  • 让 Agent 盯着自己的预算。 用同一个密钥添加 bInference MCP 服务器,Agent 就能在执行长任务前查看自己的额度。参见 MCP 服务器。
  • 内置重试。 Codex 会重试返回 503 的请求,所以模型繁忙或我们这边的短暂等待都会自行恢复。
  • 每笔订单都等你确认。 Agent 会复述每一笔下单、撤单或转账,并等你确认。
  • 两道限制保障安全: 一边是 Binance 的权限范围和子账户,另一边是这里的密钥消费上限。参见安全与限制。

本页目录