All articles

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.

Codex CLI install guide cover: a small wooden signpost with two blank arrows in green and blue
Also available in中文Español

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

RouteCommandNeeds
macOS, Linuxcurl -fsSL https://chatgpt.com/codex/install.sh | shNothing extra
Windowspowershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"PowerShell
npm, any OSnpm install -g @openai/codexNode 16 or newer
Homebrewbrew install --cask codexHomebrew
Codex CLI install methods: install script, PowerShell, npm and 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 curl or 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.

Codex CLI install and login options: ChatGPT account, API key, device code, status and logout

Three things to remember:

  • codex login status shows which sign-in method is active.
  • codex logout clears 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:

PlanPriceCodex CLI
Free$0No. Desktop app only (GPT-6 Luna, subject to rollout)
Go$8 a monthNo. Desktop app only (GPT-6 Luna, subject to rollout)
Plus$20 a monthYes, along with the web, the IDE extension and iOS
Pro$100, $200 or $500 a monthYes, with more usage
Business, Enterprise, EduPer workspaceYes
API keyAPI pricingYes, 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.

Codex CLI install and first session in five steps

These commands are useful once you’re set up:

  • codex resume reopens a recent session from the same repo.
  • codex --image attaches a screenshot to the first prompt.
  • codex cloud sends a task to Codex cloud. It needs the ChatGPT sign-in, not an API key.
  • codex mcp manages 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:

  1. Turn on device code login in your ChatGPT security settings. On a workspace, an admin turns it on in workspace permissions.
  2. Run codex login --device-auth on the server.
  3. 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.json to the server.
  • Forward the callback port with ssh -L 1455:localhost:1455 user@remote, then run codex login in 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:

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.

Leave a thought

Your email address will not be published.