Installing Codex CLI is straightforward and can be accomplished through multiple package managers or direct download. The recommended installation method is through Homebrew for macOS and Linux users, which you can execute with the simple command brew install codex
. This will download and install the latest version of the Codex CLI binary directly to your system. You can verify the installation by running codex --version
, which should display something like “codex-cli 0.2.0” for the current Rust-based version.
Alternative installation methods include using npm with the global flag: npm install -g @openai/codex
. This method works across different platforms and is particularly useful for developers who prefer Node.js package management. If you prefer manual installation, you can visit the latest GitHub Release page at github.com/openai/codex and download the appropriate binary for your specific platform. The releases include executables for various operating systems and architectures, though you’ll likely want to rename the downloaded binary to simply “codex” after extraction for easier command-line usage.
After installation, you’ll need to set up your OpenAI API key as an environment variable using export OPENAI_API_KEY="your-api-key-here"
. This command sets the key for your current terminal session, though you can add this export line to your shell’s configuration file (like ~/.zshrc) for persistent access. If you have a paid OpenAI account, you can then run the authentication process to link your CLI with your ChatGPT account. The tool also supports an upgrade command (codex --upgrade
) that allows you to fetch the latest release at any time, ensuring you always have access to the newest features and improvements.