Guide
How to install the Codex CLI on Mac, Linux and Windows
The installer for each system, npm and Homebrew, which plans include the CLI, how to sign in, including on a server, and how to keep it current.
To install the Codex CLI, run curl -fsSL https://chatgpt.com/codex/install.sh | sh on Mac or Linux, or powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" on Windows. npm install -g @openai/codex and brew install --cask codex work too. Then open a project folder, run codex, and choose Sign in with ChatGPT. The CLI needs ChatGPT Plus ($20 a month) or higher, Business, Edu or Enterprise; Free and Go include Codex only in the ChatGPT desktop app. You can also sign in with an OpenAI API key and pay per token. The latest stable release is 0.165.0, from October 27, 2026.
Key takeaways
- Mac or Linux:
curl -fsSL https://chatgpt.com/codex/install.sh | sh - Windows:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" - npm or Homebrew:
npm install -g @openai/codexorbrew install --cask codex. - Plans: the CLI is included from Plus up; Free and Go get Codex in the desktop app only.
- Sign in:
codex loginwith ChatGPT,codex login --device-authon a server, or an API key. - Update: run the installer again, or upgrade through npm or Homebrew.
| Method | Command | Systems |
|---|---|---|
| Installer | curl -fsSL https://chatgpt.com/codex/install.sh | sh | macOS, Linux, WSL |
| Installer | powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" | Windows |
| npm | npm install -g @openai/codex | Any system with npm |
| Homebrew | brew install --cask codex | macOS |
| GitHub release | Download, extract and rename to codex | macOS, Linux |
How do you install the Codex CLI on a Mac or Linux?
Open a terminal and run OpenAI's installer (OpenAI):
curl -fsSL https://chatgpt.com/codex/install.sh | sh
It downloads from releases.openai.com and falls back to GitHub Releases. If your network blocks OpenAI's download host, force GitHub instead (GitHub):
curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_INSTALLER_USE_RELEASES_OPENAI_COM=false sh
With Homebrew: brew install --cask codex. Without any installer: download the archive for your machine from the latest GitHub release, such as codex-aarch64-apple-darwin.tar.gz for an Apple Silicon Mac or codex-x86_64-unknown-linux-musl.tar.gz for Linux on Intel or AMD, extract it, and rename the binary to codex.
Run codex --version in a new terminal to check it worked.
How do you install the Codex CLI on Windows?
Open PowerShell and run:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Codex runs natively on Windows, in PowerShell, with its own Windows sandbox instead of WSL or a virtual machine. OpenAI recommends Windows 11; a fully updated Windows 10 is "best effort" and needs version 1809 or newer (OpenAI). The sandbox comes in three forms:
- MXC, recommended on Windows 11 24H2 or 25H2 builds that support it, with no administrator setup.
- Elevated, which needs an administrator to approve setup once; commands still run without administrator rights.
- Unelevated, a fallback with weaker network isolation, for when elevated setup isn't allowed.
If setup fails because you declined the Windows administrator prompt, run it again and approve it, or ask your IT team. OpenAI suggests WSL 2 only if you need Linux tools or already work in WSL; there you install with the Mac and Linux command.
Can you install Codex with npm?
Yes:
npm install -g @openai/codex
This installs the same CLI as the installer. On Windows, if PowerShell refuses with running scripts is disabled on this system, npm's .ps1 launcher is blocked: use the PowerShell installer above instead, or allow local scripts with Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser.
Which ChatGPT plans include the Codex CLI?
From OpenAI's pricing page (OpenAI):
- Free and Go ($8): Codex with GPT-6 Luna in the ChatGPT desktop app only, "subject to rollout."
- Plus ($20): the CLI, the editor extension, the web and iOS, cloud tasks and GitHub reviews, with GPT-6.1 Sol.
- Pro ($100, $200 or $500): everything in Plus with no five-hour limit.
- Business, Edu and Enterprise: included in every seat.
Limits per plan and what credits cost are in Codex pricing.
How do you sign in to the Codex CLI?
Run codex in a project folder and choose Sign in with ChatGPT, or run codex login. Your browser opens to finish (OpenAI). The other ways:
- API key:
printenv OPENAI_API_KEY | codex login --with-api-key. You pay per token at OpenAI's API prices (OpenAI API pricing), and cloud features that need a ChatGPT workspace won't work: "Codex cloud requires signing in with ChatGPT." - Device code, for a server or remote machine:
codex login --device-auth, in beta. Turn on device code login first, in your ChatGPT security settings or your workspace's permissions. - Over SSH without device codes: forward the sign-in port with
ssh -L 1455:localhost:1455 user@remoteand runcodex loginthere. Or sign in on a computer with a browser and copy~/.codex/auth.jsonacross, which works only if credentials are stored in that file. - Check or sign out:
codex login statusandcodex logout.
Codex keeps your sign-in in ~/.codex/auth.json or your system's credential store. OpenAI's advice is to treat auth.json "like a password."
How do you update Codex?
- Installer: run the same install command again.
- npm:
npm install -g @openai/codex@latest. - Homebrew:
brew upgrade --cask codex.
OpenAI releases often: 0.164.0 came out on October 23, 2026 and 0.165.0 four days later, with alpha builds of 0.166 already out (GitHub). New models can need a recent version: GPT-6.1 Terra arrived in CLI 0.165.0.
After it's installed
How to use the CLI, the editor extension, the cloud and AGENTS.md is in how to use Codex, and how it compares with Anthropic's agent in Claude Code vs Codex. Installing Claude Code instead: how to install Claude Code.
Poly (usepoly.co) runs Codex in the browser, in a shared room where a team works with one agent and anyone can approve a change before it happens. Nothing to install, and no API key. Free to start. What is Poly?
Common questions
How do I install the Codex CLI?
On Mac or Linux run curl -fsSL https://chatgpt.com/codex/install.sh | sh. On Windows run OpenAI's PowerShell installer. npm install -g @openai/codex and brew install --cask codex also work. Then run codex and sign in.
Is the Codex CLI free?
The CLI is open source under the Apache 2.0 license, but using it needs ChatGPT Plus or higher, Business, Edu or Enterprise, or an OpenAI API key billed per token. Free and Go include Codex only in the ChatGPT desktop app.
Does Codex CLI work on Windows?
Yes, natively in PowerShell with a Windows sandbox. OpenAI recommends Windows 11 and supports Windows 10 version 1809 or newer on a best-effort basis. WSL 2 also works.
How do I sign in to Codex on a remote server?
Use codex login --device-auth after turning on device code login in your ChatGPT settings. Otherwise forward port 1455 over SSH and run codex login, or copy ~/.codex/auth.json from a machine where you signed in.
How do I update the Codex CLI?
Run the install command again, or npm install -g @openai/codex@latest for npm, or brew upgrade --cask codex for Homebrew. Check the version with codex --version.