# 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.

Published 2026-10-28 by Richard Kaminsky and Mitchell Lipyansky, the co-founders of Poly. Canonical: https://usepoly.co/install-codex-cli
Poly is a multiplayer AI coding workspace: a shared room where your team works with one AI agent, together. Free to start: https://usepoly.co/

**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/codex` or `brew install --cask codex`.
- **Plans:** the CLI is included from Plus up; Free and Go get Codex in the desktop app only.
- **Sign in:** `codex login` with ChatGPT, `codex login --device-auth` on a server, or an API key.
- **Update:** run the installer again, or upgrade through npm or Homebrew.

*Ways to install the Codex CLI, from OpenAI's docs and the openai/codex repository, October 28, 2026.*

| 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](https://learn.chatgpt.com/docs/codex/cli)):

```bash
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](https://github.com/openai/codex)):

```bash
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](https://github.com/openai/codex/releases/latest), 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
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](https://learn.chatgpt.com/codex/windows/windows-sandbox)). 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:

```bash
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](https://learn.chatgpt.com/docs/pricing)):

- **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](/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](https://learn.chatgpt.com/codex/auth)). 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](/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@remote` and run `codex login` there. Or sign in on a computer with a browser and copy `~/.codex/auth.json` across, which works only if credentials are stored in that file.
- **Check or sign out:** `codex login status` and `codex 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](https://github.com/openai/codex/releases)). 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](/how-to-use-codex), and how it compares with Anthropic's agent in [Claude Code vs Codex](/claude-code-vs-codex). Installing Claude Code instead: [how to install Claude Code](/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?](/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.

More guides: https://usepoly.co/guides · Security: https://usepoly.co/security · Pricing: https://usepoly.co/pricing
