macOS、Linux 与 WSL 配置 Codex
本工具适用于 macOS、Linux 和 WSL。它会先备份现有配置,再合并 NexaGW provider,不会替换其他 provider、MCP、权限或注释。
- 已安装 Bash 和 Codex CLI。
- 已创建支持 GPT / Codex 模型的 NexaGW API Key。
- 系统提供
sha256sum或shasum。
-
下载脚本到本机
下载 nexagw-codex-setup.sh,或只下载不执行:
Terminal window curl -fL https://docs.nexagwapi.com/downloads/nexagw-codex-setup.sh \-o nexagw-codex-setup.sh -
核对 SHA-256
Terminal window sha256sum nexagw-codex-setup.shTerminal window shasum -a 256 nexagw-codex-setup.sh结果应为:
5c518571e761ef08be99c93ce625cb72862fb2762f41dcefd4aba787fe39a35f -
赋予当前用户执行权限
Terminal window chmod 700 nexagw-codex-setup.sh -
在本机运行
Terminal window ./nexagw-codex-setup.sh选择
Configure,确认后在隐藏输入中粘贴 Key。不要把 Key 放在命令行参数中,也不要把下载与执行合并成管道命令。 -
加载环境变量
重新打开终端,或按实际 shell 加载 profile:
Terminal window . "$HOME/.profile"Zsh 用户加载
~/.zshrc;已有~/.bash_profile的 Bash 用户加载该文件。 -
验证并启动 Codex
Terminal window test -n "${NEXAGW_API_KEY:-}" && echo 'NEXAGW_API_KEY is set'codex
查看状态、切换和恢复
Section titled “查看状态、切换和恢复”./nexagw-codex-setup.sh Status./nexagw-codex-setup.sh Switch hongkong./nexagw-codex-setup.sh Restore配置备份位于 ~/.codex/nexagw-backups/。工具不会修改 auth.json 或关闭任何客户端进程。
下一步:了解备份内容和手动清理方式。