Codex Mac

Codex Mac 使用教程。

当前建议分组:AppCodex 当前建议模型:gpt-5.4

(一) 安装 Node.js 环境

方法一:Homebrew

1brew install node

方法二:官网下载

  1. 打开 https://nodejs.org/
  2. 下载 LTS 安装包
  3. 按默认选项安装

验证安装:

1node --version
2npm --version

(二) 安装 Codex

1npm install -g @openai/codex --registry=https://registry.npmmirror.com

验证安装:

1codex --version

(三) 配置 Codex

编辑 ~/.codex/config.toml

 1disable_response_storage = true
 2model = "gpt-5.4"
 3model_reasoning_effort = "high"
 4model_provider = "4router"
 5
 6[model_providers.4router]
 7name = "4Router"
 8base_url = "https://4router.net/v1"
 9env_key = "4ROUTER_API_KEY"
10wire_api = "responses"

把 Key 写入 ~/.zshrc

1echo 'export 4ROUTER_API_KEY="sk-REPLACE_ME"' >> ~/.zshrc
2source ~/.zshrc

(四) 开始使用 Codex

1codex

第一次建议先跑一个最短任务:

1Print a short hello from the AppCodex group on 4Router.

(五) 常见问题

  • 配置改了没生效:重新打开 Terminal 或执行 source ~/.zshrc
  • 一直提示 provider 配置错误:确认 config.toml 没写成别的节名。
  • 请求失败:先去控制台确认当前令牌能否使用 AppCodex 分组。
  • 模型不可用:换成你账户当前可用的 Codex 模型。