Codex CLI Install: One Command for Mac, Linux and Windows
Codex CLI install guide from OpenAI's docs (Oct 21, 2026): four official install methods, which ChatGPT plans include the CLI, ChatGPT vs API key vs device code login, Windows support and headless SSH login.

On macOS or Linux, run this in a terminal:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
On Windows, open a new PowerShell window and run:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Then cd into a project folder, run codex, and choose Sign in with ChatGPT. That is the whole Codex CLI install for most people. The rest of this page covers the other two install routes, API key and device-code sign-in, servers over SSH, Windows details, and what to do when the sign-in fails.
Check your plan before you start. The CLI comes with ChatGPT Plus and higher. On Free or Go, you get Codex only in the desktop app, so the CLI won’t let you in with that account. I checked every command here against OpenAI’s Codex CLI docs and authentication page on November 18, 2026. The npm package was at version 0.169.0 that day.
Codex CLI install: all four official commands
| Route | Command | Needs |
|---|---|---|
| macOS, Linux | curl -fsSL https://chatgpt.com/codex/install.sh | sh | Nothing extra |
| Windows | powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" | PowerShell |
| npm, any OS | npm install -g @openai/codex | Node 16 or newer |
| Homebrew | brew install --cask codex | Homebrew |

I use the standalone installer. It doesn’t need Node, and running the same line again updates it. If you already work in Node, npm is fine. The package asks for Node 16 or newer, which is far less strict than Claude Code’s Node 22.
To update, use the route you installed with:
- Installer: run the same
curlor PowerShell line again. - npm:
npm install -g @openai/codex. - Homebrew:
brew upgrade --cask codex. - Any route, on versions that support it:
codex update.
Run codex --version afterwards to see which version you have.
Sign in: ChatGPT account, API key or device code
The first time you run codex, it asks how you want to sign in. Pick Sign in with ChatGPT if you want to use your plan’s Codex usage. A browser window opens, you sign in, and the browser hands the credentials back to the CLI. You can also start this flow with codex login.
To pay per token instead, sign in with an API key. OpenAI’s documented command pipes the key in, so it never lands in your shell history:
printenv OPENAI_API_KEY | codex login --with-api-key
API key usage is billed at API rates through your Platform account, not your ChatGPT plan. It also has no cloud features, such as GitHub code review and the Slack integration. OpenAI suggests API keys for CI and scripts and ChatGPT sign-in for daily work. I’d do the same.

Three things to remember:
codex login statusshows which sign-in method is active.codex logoutclears the stored credentials.~/.codex/auth.json, or your OS credential store, is where the credentials are cached. The CLI and the IDE extension share them. Treat that file like a password. Don’t commit it or paste it into a ticket.
If you sign in to ChatGPT with an email and password, you have to turn on multi-factor authentication before you can use Codex cloud. Google, Microsoft and Apple sign-ins don’t need it on the ChatGPT side.
Which ChatGPT plan includes Codex CLI
This is OpenAI’s Codex pricing page as of November 18, 2026:
| Plan | Price | Codex CLI |
|---|---|---|
| Free | $0 | No. Desktop app only (GPT-6 Luna, subject to rollout) |
| Go | $8 a month | No. Desktop app only (GPT-6 Luna, subject to rollout) |
| Plus | $20 a month | Yes, along with the web, the IDE extension and iOS |
| Pro | $100, $200 or $500 a month | Yes, with more usage |
| Business, Enterprise, Edu | Per workspace | Yes |
| API key | API pricing | Yes, without cloud features |
If you’re on Free or Go and want to try Codex, use the desktop app. I explain how the app and the CLI differ in Codex CLI vs Codex app. If you’re choosing a plan, start with ChatGPT Go vs Plus vs Pro.
Your first Codex session
Run cd to enter a repo, run codex, and ask something harmless, like “Tell me about this project”. Make a Git commit before and after each task so you can roll back. OpenAI recommends this, and it is the one habit I would insist on.
Type /status in a session to see the model, the approval policy, the folders Codex can write to, and your remaining limits. The full picture is on the usage dashboard.

These commands are useful once you’re set up:
codex resumereopens a recent session from the same repo.codex --imageattaches a screenshot to the first prompt.codex cloudsends a task to Codex cloud. It needs the ChatGPT sign-in, not an API key.codex mcpmanages MCP servers.
The CLI command reference has the full list.
Codex CLI on Windows
Codex runs natively in PowerShell. It doesn’t need WSL or a virtual machine. OpenAI’s Windows page recommends Windows 11. A recent, fully updated Windows 10 can work, but it is less reliable than Windows 11. On Windows 10, Codex depends on modern console support, including ConPTY, so in practice you need version 1809 or newer. Older Windows 10 builds are not recommended.
Codex runs commands inside a Windows sandbox that limits which files and which network access they get. The recommended sandbox is MXC, which needs no administrator setup. MXC needs Windows 11 24H2 or 25H2 with Microsoft’s MXC capabilities, which Microsoft is still rolling out.
Only the desktop app picks MXC automatically, and only for personal accounts on devices that support it. The standalone CLI doesn’t. To use MXC from the CLI, add this to Codex’s config.toml:
[features]
prefer_mxc = true
Without this setting, the CLI keeps the older sandbox, which needs a one-time setup approved by an administrator.
Use WSL2 if your project already lives in Linux or needs Linux-only tools. In that case, install with the curl line inside WSL, not the PowerShell line. If the Windows CLI opens and closes right away, see Codex could not start its user interface.
Sign in on a server or over SSH
The browser sign-in returns a token to a localhost callback, so it fails on a machine with no browser. OpenAI’s preferred fix is device code sign-in, which is still in beta:
- Turn on device code login in your ChatGPT security settings. On a workspace, an admin turns it on in workspace permissions.
- Run
codex login --device-authon the server. - Open the link on any device and enter the code.
If device code sign-in isn’t available to you, the docs give two fallbacks:
- Sign in on a machine with a browser, then copy
~/.codex/auth.jsonto the server. - Forward the callback port with
ssh -L 1455:localhost:1455 user@remote, then runcodex loginin that SSH session.
If the browser shows “localhost refused to connect” at the end of sign-in, the callback port is the problem. The fix is in Codex localhost refused to connect.
When the Codex CLI install or sign-in breaks
Run codex doctor first. It writes a local report on the install, the config, sign-in, Git and the terminal. A direct codex login also writes codex-login.log to your log folder. Support asks for that file.
On a corporate network with a TLS proxy, set CODEX_CA_CERTIFICATE to your PEM bundle before you sign in.
Match the error you see:
Token exchange failedwith 403 Forbidden or “error sending request”: the Codex process has no working proxy settings, or~/.codex/.envstill points at an old proxy port. See Codex token exchange failed.- 401 “Incorrect API key provided”: the key is wrong or no longer active. See OpenAI 401 Incorrect API key provided.
- “stream disconnected before completion”: the connection dropped mid-answer. See Codex stream disconnected before completion.
- “Selected model is at capacity”: the model is busy, not your install. See Selected model is at capacity in Codex.
If your limits look wrong, check the Claude and Codex usage limit tracker, where I log every official change.
Codex CLI next to Claude Code
Plenty of people run both. Claude Code has an official /import codex command that copies over your instructions and MCP servers (commands reference). To install it, see the Claude Code install guide. To pick one of the two, read Claude Code vs Codex.
Codex CLI install FAQ
What is the Codex CLI install command? On macOS and Linux it is curl -fsSL https://chatgpt.com/codex/install.sh | sh. On Windows, run irm https://chatgpt.com/codex/install.ps1 | iex through PowerShell. You can also use npm install -g @openai/codex or brew install --cask codex.
Is Codex CLI free? Installing it is free. Using it needs ChatGPT Plus or higher, or an API key billed per token. Free and Go accounts get Codex only in the desktop app.
Does Codex CLI need Node.js? Only for the npm route, which needs Node 16 or newer. The curl, PowerShell and Homebrew installs don’t use Node.
Does Codex CLI work on Windows 10? Yes, on a fully updated Windows 10, version 1809 or newer, but OpenAI calls it best effort and recommends Windows 11.
What is the latest Codex CLI version? 0.169.0 on npm as of November 18, 2026. Run codex --version to see yours, and codex update or the install line to upgrade.
How do I sign in to Codex CLI without a browser? Turn on device code login in ChatGPT security settings, then run codex login --device-auth.
Where do I see my Codex limits? Type /status in a session, or open the usage dashboard.
How much does Codex cost compared with other tools? Plan and API prices across vendors are in my AI subscription and API price comparison.
More on this: Claude Code vs Codex · Claude and Codex usage limit tracker · AI subscription and API price comparison · OpenAI category
Related: Is Codex free? What ChatGPT Free gets and what needs a paid plan.
Related: Codex pricing: Plus vs Pro vs API key, and what one task costs.