Codex CLI is OpenAI's coding agent for the terminal, and it installs three ways: the official script, npm, or Homebrew on a Mac. On Windows the native PowerShell install needs no WSL. This article covers only the CLI: commands per system, where the files go, and what breaks first. If you are still choosing between the desktop app, the CLI and the editor extension, read Download Codex: app, CLI and VS Code extension first, then come back here for the terminal side.
Install on macOS and Linux
The route OpenAI lists first is the install script:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
The script detects your processor and fetches the matching binary: Apple Silicon or x86_64 on a Mac, x86_64 or arm64 on Linux. It puts codex in ~/.local/bin and, if that folder is not on your PATH yet, adds it through your shell profile (~/.zprofile on macOS with zsh, ~/.bashrc on Linux with bash). The same command updates an existing install, so running it again pulls the newest version over the old one. It downloads from releases.openai.com/codex and falls back to GitHub Releases if that source fails. To force GitHub, set CODEX_INSTALLER_USE_RELEASES_OPENAI_COM=false before the command.
Homebrew (Mac)
If Homebrew already manages your tools, there is a cask:
brew install --cask codex
Later updates use brew upgrade --cask codex.
npm (Mac, Linux, Windows)
Codex CLI is also published as an npm package, which is handy when Node.js is already there and you prefer one package manager:
npm install -g @openai/codex
You need Node.js for this route. The package declares Node.js 16 or newer in its package.json, and a current LTS release is fine. If npm install fails with a syntax error or an unknown-flag error, the likeliest cause is a Node version that is too old.
Install on Windows
The native route, with no WSL, is one command in PowerShell:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Start it from a new PowerShell window. The -ExecutionPolicy ByPass part comes from the official install command: it sets the execution policy for that PowerShell process only. A Group Policy set by your organization takes priority over the flag.
The script supports x64 and ARM64. It installs codex in %LOCALAPPDATA%\Programs\OpenAI\Codex\bin and adds that folder to your user PATH, so you do not edit PATH by hand. Open a new terminal window afterwards, because the one you ran it in will not see the change. The terminal inside VS Code counts as a terminal too.
The npm package works on Windows as well, if Node.js is installed:
npm install -g @openai/codex
What Windows version do you need? OpenAI recommends Windows 11. A recent, fully updated Windows 10 is supported on a best-effort basis, and in practice version 1809 or newer is required, because Codex depends on modern console support. Older Windows 10 builds are not recommended. WSL is optional: if you choose it, use WSL2, since WSL1 was supported through Codex 0.114 and dropped from 0.115 when the Linux sandbox moved to bubblewrap.
Download the binary directly
For CI, containers, or any machine where piping a script from the internet is unwelcome, GitHub Releases has ready-made files. Release 0.167.0, published on November 6, 2026, includes codex-aarch64-apple-darwin.tar.gz and codex-x86_64-apple-darwin.tar.gz for Mac, codex-x86_64-unknown-linux-musl.tar.gz and codex-aarch64-unknown-linux-musl.tar.gz for Linux, and codex-x86_64-pc-windows-msvc.exe plus an ARM64 build for Windows, in .zip and .tar.gz form too.
The repository's README lists only the macOS and Linux archives and tells you to rename the extracted file to codex. These are the same binaries the script installs, minus the automation: you unpack the archive and put it on your PATH yourself. An offline install works the same way. Download on a connected machine, move the file across, unpack it and add the folder to PATH.
Sign in after installing
Run codex in a project folder. The first launch offers Sign in with ChatGPT or another sign-in method. There are two doors: a ChatGPT account, or an API key.
For an API key, pipe it through standard input:
printenv OPENAI_API_KEY | codex login --with-api-key
On a remote or headless machine, OpenAI's docs prefer device-code sign-in (beta): codex login --device-auth. Cached credentials live in ~/.codex/auth.json or in your system's credential store, and the file deserves the same care as a password.
Where OpenAI's sign-in or billing is not available to you, the CLI can talk to another provider through ~/.codex/config.toml (on Windows %USERPROFILE%\.codex\config.toml). A gateway such as Claudexia, a third-party service that accepts OpenAI-style requests at its own address, takes this config:
model_provider = "claudexia"
model_reasoning_effort = "medium"
model = "gpt-6-sol"
[model_providers.claudexia]
name = "Claudexia"
base_url = "https://api.claudexia.tech/v1"
wire_api = "responses"
env_key = "CODEX_KEY"
Set the key in the variable before launching Codex:
$env:CODEX_KEY = "sk_cdx_YOUR_KEY"
export CODEX_KEY="sk_cdx_YOUR_KEY"
Add the bash line to ~/.bashrc or ~/.zshrc to keep it. A step-by-step version for all three systems is in the Codex guide. You get a key after you create an account. Claudexia does not sell ChatGPT plans, and whether a gateway is allowed from your country is a question for the terms of the provider you use. OpenAI's own supported-countries page for its API does not list, among others, China, Russia, Belarus, Iran, Cuba, Syria or Venezuela.
Common errors after installation
| What you see | Likely cause | What to do |
|---|---|---|
command not found: codex | The terminal was opened before the install, so its PATH is old | Open a new terminal. On macOS and Linux you can also run source ~/.zshrc or source ~/.bashrc |
| PowerShell refuses to run the script | A strict execution policy on the machine | Run the whole install command as shown above, not a bare link to install.ps1; a Group Policy from an administrator is not overridden by the flag |
npm install fails with a permissions error | Node.js was installed through a system package manager with no user prefix | Point npm's global prefix at your home directory instead of fixing it with sudo each time |
| Codex asks you to sign in although you have a key | config.toml was not picked up, or the variable is not set in this shell | Check that the file sits in the right folder for your system and that the env_key variable is set in the shell that starts codex |
| Unknown model | The model value is sent as written | Match the ID to the provider's catalog, for example GET https://api.claudexia.tech/v1/models |
| WSL1 error or sandbox failure | WSL1 is not supported since Codex 0.115 | Switch the distribution to WSL2 or use the native Windows install |
FAQ
How do I install Codex CLI on Windows without WSL?
In a new PowerShell window run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex". The install is native, and WSL is not needed.
Are Codex CLI and the Codex app the same thing?
No. Codex CLI is the terminal agent. The macOS and Windows app is called the ChatGPT desktop app, and Codex has been a mode inside it since the merge OpenAI dates to July 9. The codex app command in the CLI launches that app. The comparison of app, CLI and extension is in Download Codex.
What should I check if Codex shows an error on first launch?
If you installed through npm, check the Node.js version. Then make sure PATH refreshed in the current terminal. For an authentication error, look at ~/.codex/config.toml and the environment variable that holds the key.
Do I need separate installers for the ChatGPT desktop app and the CLI?
Yes. The desktop app installs as an application for macOS or Windows, and Codex lives inside it as a mode. The CLI has its own script, or npm, or Homebrew, as described above.
Can I install the CLI without internet access, from a local file?
Yes, from an archive on GitHub Releases. Download it on another machine, copy it over, unpack it and add the folder to PATH.
Is Codex CLI open source?
Yes. The repository on GitHub is licensed under Apache-2.0, and the npm package carries the same license.