跳转到内容

macOS、Linux 与 WSL 配置 Codex

本工具适用于 macOS、Linux 和 WSL。它会先备份现有配置,再合并 NexaGW provider,不会替换其他 provider、MCP、权限或注释。

  • 已安装 Bash 和 Codex CLI。
  • 已创建支持 GPT / Codex 模型的 NexaGW API Key。
  • 系统提供 sha256sumshasum
  1. 下载脚本到本机

    下载 nexagw-codex-setup.sh,或只下载不执行:

    Terminal window
    curl -fL https://docs.nexagwapi.com/downloads/nexagw-codex-setup.sh \
    -o nexagw-codex-setup.sh
  2. 核对 SHA-256

    Terminal window
    sha256sum nexagw-codex-setup.sh

    结果应为:

    5c518571e761ef08be99c93ce625cb72862fb2762f41dcefd4aba787fe39a35f
  3. 赋予当前用户执行权限

    Terminal window
    chmod 700 nexagw-codex-setup.sh
  4. 在本机运行

    Terminal window
    ./nexagw-codex-setup.sh

    选择 Configure,确认后在隐藏输入中粘贴 Key。不要把 Key 放在命令行参数中,也不要把下载与执行合并成管道命令。

  5. 加载环境变量

    重新打开终端,或按实际 shell 加载 profile:

    Terminal window
    . "$HOME/.profile"

    Zsh 用户加载 ~/.zshrc;已有 ~/.bash_profile 的 Bash 用户加载该文件。

  6. 验证并启动 Codex

    Terminal window
    test -n "${NEXAGW_API_KEY:-}" && echo 'NEXAGW_API_KEY is set'
    codex
Terminal window
./nexagw-codex-setup.sh Status
./nexagw-codex-setup.sh Switch hongkong
./nexagw-codex-setup.sh Restore

配置备份位于 ~/.codex/nexagw-backups/。工具不会修改 auth.json 或关闭任何客户端进程。

下一步:了解备份内容和手动清理方式