How to Install Codex CLI
To install OpenAI's Codex CLI, run curl -fsSL https://chatgpt.com/codex/install.sh | sh on macOS or Linux, or the PowerShell installer on Windows (npm install -g @openai/codex and brew install --cask codex also work), then run codex in a project folder and sign in with ChatGPT. Steps for every system, WSL, updating, removing and fixing common problems, as of Nov 6, 2026.
To install Codex CLI on a Mac or Linux, run curl -fsSL https://chatgpt.com/codex/install.sh | sh in a terminal; on Windows, open a new PowerShell window and run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex". Then type codex in a project folder and choose Sign in with ChatGPT (OpenAI docs). npm (npm install -g @openai/codex) and Homebrew (brew install --cask codex) work too. Every ChatGPT plan includes Codex, Free and Go too, so no extra subscription is needed to try it (Codex Pricing and Limits).
This guide covers each system step by step. What the CLI can do once it runs is on Codex CLI. If you would rather not use a terminal, the Codex App (the Codex view of the ChatGPT desktop app) and the Codex IDE Extension do the same work.
Quick facts
| macOS and Linux | curl -fsSL https://chatgpt.com/codex/install.sh | sh (docs) |
| Windows (PowerShell) | powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" |
| npm | npm install -g @openai/codex |
| Homebrew | brew install --cask codex |
| Update | Run the same installer again; Homebrew: brew upgrade --cask codex |
| Check the version | codex --version (Troubleshooting) |
| Latest version | 0.166.0, Oct 29, 2026 |
| WSL | WSL2 only; WSL1 stopped working after 0.114 |
Install Codex CLI on macOS
- Open Terminal.
- Run
curl -fsSL https://chatgpt.com/codex/install.sh | sh. If you use Homebrew, runbrew install --cask codexinstead. - Check it worked:
codex --versionprints the version. - Go to a project:
cd ~/code/my-project. - Run
codex, choose Sign in with ChatGPT, and finish signing in in the browser window that opens.
Source: Codex CLI, Authentication, OpenAI docs, read Nov 6, 2026. On macOS the sandbox uses Apple's built-in Seatbelt framework, so nothing else needs installing (Sandboxing). Codex may ask for access to protected folders such as Music, Downloads or Desktop if a task reaches into your home folder; macOS shows its own prompt for each (Troubleshooting).
Install Codex CLI on Linux
- Open a terminal.
- Run
curl -fsSL https://chatgpt.com/codex/install.sh | sh, ornpm install -g @openai/codexif you prefer npm. - Run
codex --versionto check, thencodexinside a project folder and sign in.
On Linux the sandbox uses bubblewrap (bwrap), with a bundled helper as a fallback (Sandboxing). On a server with no browser, sign in with codex login --device-auth (see Sign in without a browser below).
Install Codex CLI on Windows
- Open a new PowerShell window (Windows Terminal works).
- Run
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex". - Open a project folder in PowerShell and run
codex, then sign in.
Source: Codex CLI, read Nov 6, 2026. Codex runs natively on Windows, with a Windows sandbox around its commands. The recommended sandbox, MXC, needs no administrator setup on compatible devices; the older elevated sandbox needs administrator approval once, and /setup-default-sandbox in the CLI sets it up (Windows sandbox, Developer commands). codex doctor checks a broken installation on any system (Developer commands).
Install Codex CLI in WSL
Use WSL2 when your code and tools already live in Linux. In WSL, Codex runs inside Linux and uses the Linux sandbox instead of the Windows one (Windows WSL).
- In an administrator PowerShell, run
wsl --install(Ubuntu is the usual choice), thenwslto open a Linux shell. - In that shell, run
curl -fsSL https://chatgpt.com/codex/install.sh | sh. - Run
codex.
Keep repositories under your Linux home folder (~/code/my-app), not under /mnt/c/...: Windows-mounted paths are slower and cause more symlink and permission trouble. WSL1 was supported through Codex 0.114; from 0.115 the Linux sandbox needs bubblewrap, so WSL1 no longer works (Windows WSL).
Install Codex CLI with npm or Homebrew
- npm, on any system with Node.js:
npm install -g @openai/codex. Run the same command to update. - Homebrew, on macOS:
brew install --cask codex; update withbrew upgrade --cask codex.
Source: Codex CLI, read Nov 6, 2026. The CLI's package is @openai/codex; the programming library is a separate package, @openai/codex-sdk (see Codex SDK).
Sign in
Codex offers two kinds of sign-in for local work (Authentication):
- Sign in with ChatGPT uses your plan's included Codex usage. Run
codex(orcodex login) and complete the browser flow. Codex Cloud works only this way. - API key bills usage at API prices:
printenv OPENAI_API_KEY | codex login --with-api-key. Get a key from the OpenAI dashboard. See OpenAI API Pricing.
codex login status exits with 0 when credentials are present, and codex logout removes them (Developer commands). Codex caches the login in ~/.codex/auth.json or in your system's credential store; treat that file like a password (Authentication).
Sign in without a browser
On a remote or headless machine the browser flow may fail. Use device code sign-in (beta): turn on device code login in your ChatGPT security settings (or ask a workspace admin), run codex login --device-auth, open the link on any device and enter the one-time code. If that is not available, sign in on a machine with a browser and copy ~/.codex/auth.json to the same place on the remote machine, or forward the sign-in callback port with ssh -L 1455:localhost:1455 user@remote (Authentication).
Run a first task
In the project folder, run codex and ask something safe first, such as "Tell me about this project". Make a Git commit before and after each task so you can undo changes (Codex CLI). By default Codex can edit files and run commands only inside the folder, with the network off, and asks before doing more (Agent approvals and security). Type /init to have Codex write an AGENTS.md file with your project's rules.
Update Codex CLI
- Standalone installer (macOS, Linux, Windows): run the install command again.
- npm:
npm install -g @openai/codex. - Homebrew:
brew upgrade --cask codex. - Any install where the release supports self-update:
codex update.
Source: Codex CLI, Developer commands, read Nov 6, 2026. Some models need a recent CLI: GPT-6 Astra needs 0.153.0 or newer and GPT-6.1 Terra 0.159.0 or later.
Uninstall Codex CLI
OpenAI's documentation read on Nov 6, 2026 gives no uninstall steps for the standalone installers. For npm and Homebrew installs, remove the package with that package manager (npm uninstall -g @openai/codex, or brew uninstall --cask codex). Your settings, chats and cached login live in the Codex home folder, ~/.codex unless CODEX_HOME points elsewhere (AGENTS.md docs, Authentication); delete it only if you want them gone. On Windows, if you set up the legacy elevated sandbox, codex sandbox uninstall run as administrator removes its machine-wide accounts and network rules (Developer commands).
Troubleshooting
"npm.ps1 cannot be loaded because running scripts is disabled on this system." PowerShell's execution policy is blocking npm's scripts. OpenAI's suggested fix is Set-ExecutionPolicy -ExecutionPolicy RemoteSigned; read Microsoft's guide to execution policies before changing it (Windows app).
codex is not found after an npm install. npm's global folder is not on your PATH. Add it, or open a new terminal after installing. (OpenAI gives the same advice for its codex-security package; Codex Security CLI.)
Sign-in hangs or never returns to the terminal. Your network may block the local callback Codex uses after the browser sign-in. Use codex login --device-auth, or forward port 1455 over SSH (Authentication).
Certificate errors behind a company proxy. Set CODEX_CA_CERTIFICATE to your company's PEM certificate bundle before codex login (Authentication).
A feature works in the CLI but not in the app, or the other way round. The CLI and the ChatGPT desktop app can carry different Codex versions; compare them with codex --version (Troubleshooting).
Slow in WSL. Move the repository out of /mnt/c into your Linux home folder (Windows WSL).
Anything else. Run codex doctor for a report on installation, configuration, sign-in, Git and the terminal, and include it when you ask for help (Developer commands). General ChatGPT outages are covered on ChatGPT Not Working.
Frequently asked questions
How do I install Codex CLI on Windows? Open a new PowerShell window and run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex", then run codex in a project folder and sign in with ChatGPT. You can also install Codex CLI inside WSL2 with the Linux command.
What is the npm package for Codex CLI? The Codex CLI's npm package is @openai/codex: install it with npm install -g @openai/codex and run the same command to update.
Do I need a paid ChatGPT plan to use Codex CLI? No. Codex CLI works with every ChatGPT plan, including Free and Go, though free use is limited; you can also sign in with an OpenAI API key and pay per token.
How do I update Codex CLI? Run the same install command again (curl, PowerShell or npm), use brew upgrade --cask codex with Homebrew, or run codex update where your release supports it.
How do I sign in to Codex CLI on a server without a browser? Run codex login --device-auth and enter the one-time code on another device, after turning on device code login in your ChatGPT security settings. Copying ~/.codex/auth.json from a machine where you already signed in also works.
Does Codex CLI work in WSL1? No. Codex CLI supported WSL1 through version 0.114; from 0.115 it needs WSL2, because its Linux sandbox uses bubblewrap.
Sources
- Codex CLI, OpenAI docs, read Nov 6, 2026
- Authentication, OpenAI docs, read Nov 6, 2026
- Developer commands, OpenAI docs, read Nov 6, 2026
- Troubleshooting, OpenAI docs, read Nov 6, 2026
- Sandboxing, OpenAI docs, read Nov 6, 2026
- Windows sandbox, OpenAI docs, read Nov 6, 2026
- Windows WSL, OpenAI docs, read Nov 6, 2026
- ChatGPT desktop app for Windows, OpenAI docs, read Nov 6, 2026
- Agent approvals and security, OpenAI docs, read Nov 6, 2026
- Custom instructions with AGENTS.md, OpenAI docs, read Nov 6, 2026
- Models, OpenAI docs, read Nov 6, 2026
- Changelog, OpenAI docs, read Nov 6, 2026
- Codex Security CLI quickstart, OpenAI docs, read Nov 6, 2026
- ChatGPT Work and Codex, OpenAI Help Center, read Nov 6, 2026
- Using OpenAI Codex CLI with GPT-5-Codex, OpenAI, Oct 14, 2025 (video)
- OpenAI Codex CLI, OpenAI, Apr 16, 2025 (video)
Moments
Using OpenAI Codex CLI with GPT-5-Codex
OpenAI
OpenAI Codex CLI
OpenAI
See also
-
Codex Pricing and LimitsCodex comes with every ChatGPT plan as of Nov 6, 2026: Free ($0) and Go ($8) get GPT-6 Luna in the desktop app, Plus ($20) gets about 15 to 160 GPT-6.1 Sol messages per five hours plus Codex Cloud, and Pro ($100, $200 or $500) has no five-hour limit. Credits extend any plan, and an API key bills by the token instead.
-
Codex CLICodex CLI is OpenAI's open-source coding agent for the terminal: install it with one command, run codex in a project folder, sign in with ChatGPT or an API key, and it reads, edits and runs your code inside a sandbox. This page covers its commands, models, approval modes, config.toml, codex exec, resume and MCP as of Nov 6, 2026. -
Codex AppThe Codex app is now the Codex view of the ChatGPT desktop app for macOS, Windows and Linux, where Codex runs parallel chats, worktrees, Computer Use, Appshots, Goal mode, Record and Replay and remote control from a phone. It replaced the standalone Codex app OpenAI launched on Feb 2, 2026. -
Codex IDE ExtensionThe Codex IDE extension puts OpenAI's coding agent beside your code in VS Code, Cursor, Windsurf and VS Code Insiders (Marketplace id openai.chatgpt), while Xcode and JetBrains IDEs offer Codex through their own AI assistants. It uses the same ChatGPT plan, models and config.toml as the Codex CLI and the ChatGPT desktop app. - Codex SDKThe Codex SDK lets programs run OpenAI's Codex agent: npm install @openai/codex-sdk for TypeScript (Node.js 18 or later) or pip install openai-codex for Python (3.10 or later). For CI there is also codex exec, the non-interactive CLI mode, and the GitHub Action openai/codex-action@v1; the App Server is the protocol for building full Codex clients.
-
Codex CloudCodex Cloud runs OpenAI's coding agent on OpenAI's servers: you connect GitHub repositories, publish a cloud environment, and start tasks from ChatGPT on the web, the desktop app or a phone, each in its own workspace that keeps working while your computer sleeps. It needs ChatGPT Plus or higher; Free and Go do not include it.