Amux
安装指南

安装 Codex CLI

下载并安装 OpenAI 的 Codex CLI

Codex CLI 是 OpenAI 的开源 AI 编程代理,在终端中运行。它提供三种安全模式(建议、自动编辑、全自动),并使用操作系统级别的沙箱来保障安全。

系统要求

要求最低配置
操作系统macOS、Linux、Windows(通过 WSL)
Node.js18+(仅 npm 安装方式需要)
网络需要互联网连接
账号ChatGPT Plus/Pro/Team/Business/Edu/Enterprise,或 OpenAI API Key

安装

npm

npm install -g @openai/codex

Homebrew (macOS)

brew install --cask codex

GitHub Releases

GitHub Releases 页面下载对应平台的二进制文件(macOS Intel/Apple Silicon、Linux x86_64/arm64)。

验证安装

codex --version

认证

方式一:ChatGPT 订阅(推荐)

运行 codex 并选择 "Sign in with ChatGPT",会打开浏览器进行认证。无需额外付费。

codex

方式二:API Key

export OPENAI_API_KEY="sk-..."
codex

远程 / SSH 访问

通过 SSH 使用 Codex CLI 时,需要转发认证端口:

ssh -L 1455:localhost:1455 user@your-server
codex

快速上手

交互式会话:

codex

单次命令:

codex "explain what this codebase does"

全自动模式:

codex --full-auto "Run tests and fix failures"

安全模式

模式描述
Suggest仅建议,不修改文件
Auto Edit自动编辑文件,执行命令需批准
Full Auto完全自动化,无需批准

Codex CLI 使用操作系统级别的沙箱(macOS Seatbelt、Linux Landlock),默认阻止网络访问以保障执行安全。

配合 Amux API Platform 使用

安装 Codex CLI 后,详见在 Codex CLI 中使用,将其连接到 Amux API Platform。

你也可以通过 Amux Desktop 代理路由 Codex CLI:

export OPENAI_BASE_URL="http://127.0.0.1:9527/proxies/{proxyPath}"
export OPENAI_API_KEY="sk-amux.xxx"
codex

相关资源

On this page