On this pageFirst, choose the right Codex product

How to Install Codex CLI on Windows, macOS and Linux

Xtrusio9 min read

Short answer

To install Codex CLI, use OpenAI's standalone installer for your operating system or the documented npm package, then open a project directory and run codex. On first launch, choose a supported sign-in method and give it one small task. Windows PowerShell and WSL are different environments: install the CLI in the one where you will work.

How to Install Codex CLI on Windows, macOS and Linux

You will learn: which installer to choose; the first commands on macOS, Linux, Windows PowerShell and WSL; how to check that your terminal finds the right executable; how to update or remove the version you installed; and how Codex CLI differs from Claude Code.

First, choose the right Codex product

Codex CLI is the terminal coding agent. It opens in a project folder, reads files you allow it to inspect, can edit code, and can run local commands under the permissions you choose. The separate openai CLI is for calling OpenAI's REST API from a terminal. The ChatGPT desktop app has its own installer. Installing one does not automatically give you the codex command you expect. OpenAI's Codex CLI guide and OpenAI's API CLI guide describe those different jobs.

Pick the environment where your repository actually lives:

  • macOS or Linux: use the standalone installer below. The official Codex repository README also documents npm and Homebrew alternatives.
  • Windows PowerShell: use the official PowerShell installer or npm. A separate OpenAI.Codex package appears in Microsoft's community WinGet repository; verify the package ID and its release source if your team uses WinGet.
  • Windows with WSL2: install Codex inside your Linux distribution. A Windows-installed CLI and a WSL-installed CLI have separate command paths and environments. The OpenAI WSL guide recommends keeping Linux projects in the Linux home directory.

You need an account with Codex access or the supported API-key setup, a terminal, and a project folder. The installation steps were checked against OpenAI's pages on 19 October 2026.

Install on macOS or Linux

Open a terminal and run the standalone installer command shown by OpenAI:

```sh
curl -fsSL https://chatgpt.com/codex/install.sh | sh
```

Open a new terminal after installation, move into a project, and start Codex:

```sh
cd path/to/your-project
codex
```

The first command retrieves and runs OpenAI's install script. In a managed workplace, review that source and use your approved software process before executing it. The script's published source shows the default command location under the user's local bin directory and a managed standalone package directory under the Codex home. If your organization does not allow pipe-to-shell installers, the official README also documents package-manager and release-asset options. Choose one method and remember it for updates and removal.

If Node.js and npm are already installed, OpenAI's README documents this alternative:

```sh
npm install -g @openai/codex
```

Homebrew users can use the cask command in that same README. The distinction matters because an old formula and the current cask can put different codex commands on your path. After installation, confirm which one your shell resolves before starting work.

Install on Windows PowerShell

Open PowerShell as the Windows user who will run Codex. The official OpenAI Codex README gives the standalone Windows command:

```powershell
powershell -ExecutionPolicy Bypass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
```

This retrieves and executes the OpenAI PowerShell installer. For a managed deployment, OpenAI's Windows deployment guide instead explains how IT can review the installer, pin an approved release and run it in the intended user's context. Do not run an installer as a system account and assume it placed the command in each employee's profile.

Close PowerShell, open a new window, then check which command will run:

```powershell
Get-Command codex
```

If it points to the intended install, open your repository and start the CLI:

```powershell
Set-Location 'C:\path\to\your-project'
codex
```

Replace the example path with your real project folder. OpenAI's Windows deployment guide says the standalone installer normally exposes a command under the user's local application data and adds it to the user path. A fresh PowerShell window matters because an older session may not see that path change. The installer source shows the default locations and supported 64-bit architectures.

If your Windows machine already has a managed Node.js and npm installation, the official README also supports npm install -g @openai/codex. Use your organization's approved package version and install context. Microsoft's community WinGet manifest for OpenAI.Codex also points to OpenAI's Codex CLI release files. If you choose that route, inspect the package ID and version before running winget install OpenAI.Codex, then verify Get-Command codex. This community manifest is a different source from OpenAI's documented standalone installer.

Install inside WSL2

If your development files and tools live inside Windows Subsystem for Linux, open that Linux shell with wsl from PowerShell. If WSL is not set up yet, follow OpenAI's WSL prerequisites and setup guide and your organization's Windows software policy first. Codex's current Linux sandbox requires WSL2 rather than WSL1, according to that guide.

Within the WSL shell, move to a Linux-side project folder and run the Linux installer:

```sh
cd ~/code/your-project
curl -fsSL https://chatgpt.com/codex/install.sh | sh
codex
```

The WSL installation is separate from the Windows PowerShell installation. If codex works in PowerShell but not in WSL, that is a path and environment distinction, not evidence that the Linux command is broken. OpenAI recommends keeping active WSL repositories under the Linux home directory for better file-system behavior than a Windows-mounted path.

Sign in and give Codex its first task

Run codex from the project directory. On first launch, the Codex CLI guide says to choose Sign in with ChatGPT or another available method. The authentication guide explains the supported account and credential routes. Do not paste an API key into a public issue, screenshot or project file.

Start with a bounded, read-only question such as “Explain how this project runs its tests and point me to the relevant configuration files.” Review the files Codex inspected and the answer it gave. Before asking it to edit, check the current permission setting and keep a Git checkpoint. The CLI's command reference documents its interactive commands and permission controls. A successful sign-in shows that your account can start a session; it does not prove that a particular repository change is safe to accept.

In a dated local check on 19 October 2026, PowerShell resolved an existing codex command and its version query returned codex-cli 0.163.0-alpha.10.2. This confirms only the command and version on that machine, not a fresh installation or an edited project.

Four setup problems and the next check

The terminal says codex is not recognized. Open a new terminal and run Get-Command codex in PowerShell or command -v codex on macOS, Linux or WSL. If neither finds it, check whether the installer completed under a different user and whether its command directory is on that user's path. OpenAI's Windows deployment guide specifically warns that a system-context installer targets the system profile, not every employee.

The wrong Codex version starts. Use the same command-location check to find competing installs. If both a standalone installer and npm placed a codex command on the machine, path order decides which one runs. Remove or update the unintended installation through its own method after you identify it. Do not delete an unknown executable just because its filename matches.

PowerShell works, but WSL does not. Check inside WSL, not in PowerShell. Install within WSL if that is where the repository and tools live. OpenAI's WSL troubleshooting guide covers command-path and project-location issues.

Sign-in does not finish. Check that you are using the intended account and method, then follow OpenAI's authentication guide. Managed organizations may constrain sign-in or require a particular account. Treat an authentication failure separately from a missing command. Do not put credentials in a troubleshooting screenshot.

Update or uninstall without losing project data

For an installed CLI release that supports it, OpenAI's CLI reference documents codex update as the self-update command. Managed deployments should instead use the version and rollout process chosen by IT. If you installed with npm, update the approved @openai/codex package through npm; if you installed with Homebrew, update its Codex cask. The Windows deployment guide recommends verifying the executable location and intended account after an update.

For removal, first find which installation your shell is using. An npm install can be removed with:

```sh
npm uninstall -g @openai/codex
```

For Homebrew, remove the Codex cask through Homebrew. For a standalone install, review the official macOS and Linux installer source or Windows installer source for the command and managed package paths selected on your machine, then remove only that install through your approved process. The CLI documentation does not present a universal uninstall command for every method. Preserve your repository and Codex configuration or session data unless you separately decide to remove them. Reopen the terminal and confirm that the old command no longer resolves.

Codex CLI or Claude Code?

Both are terminal coding agents that can read a codebase, propose edits and run local development tools. OpenAI's Codex CLI guide and Anthropic's Claude Code overview describe those core workflows. Choose based on the account and permissions your team supports, the project environment, and which agent's output you can review and test well. Do not choose from a social clip that shows only a fast prompt and no diff, command history or failure path.

If you already use Claude Code, try Codex CLI on the same small, nonproduction task and compare the proposed plan, changed files, test command and final result. That is a fair local comparison. We did not run a head-to-head benchmark for this guide, so no winner or speed claim follows from it.

Measure whether your setup guide becomes a cited source

If your team publishes a guide like this, check whether it answers a specific reader question, such as “How do I install Codex CLI in Windows PowerShell?” Save the exact question, dated AI answer and cited URLs. After publishing, ask the same question again and see whether the engine cites the exact guide URL. A brand mention is not the same as a citation to the page that solved the install problem. Xtrusio's AI visibility explainer describes that question-level check. It measures an outcome; publication alone does not guarantee one.

Sources and scope

Checked 19 October 2026: OpenAI Codex CLI guide, OpenAI Windows deployment guide, OpenAI WSL guide, OpenAI authentication guide, OpenAI CLI reference, official Codex README, and the official installer sources. Anthropic's Claude Code overview supports the brief comparison only.

Frequently asked questions

Is the OpenAI CLI the same as Codex CLI?

No. Codex CLI runs the coding agent with the `codex` command. OpenAI's separate API CLI uses `openai` to make API requests. Check the Codex CLI guide and the OpenAI API CLI guide before installing.

Can I install Codex CLI with WinGet?

Yes, Microsoft's community WinGet repository lists `OpenAI.Codex` for the CLI. Verify that exact package ID and its release source before using `winget install OpenAI.Codex`. OpenAI's own Codex Windows CLI instructions document the standalone installer; their WinGet instruction for the ChatGPT desktop app refers to a different product.

Do I need WSL on Windows?

No. Use PowerShell for a native Windows project. Use WSL2 when your repository and development tools are in Linux. The CLI must be installed in the environment from which you plan to run it. See OpenAI's WSL guide.

Can I sign in with ChatGPT instead of an API key?

Yes, where your account has Codex access. The Codex README and authentication guide explain the routes. Do not assume that an API key and a ChatGPT plan have the same billing or access controls.

What should I check before accepting Codex's first edit?

Read the file diff, the command it ran, and the test result in your own project. A plausible summary does not replace reviewing the changed code. Keep a Git checkpoint so you can revert an unwanted change.

Topics

  • how to install codex cli

Xtrusio

AI visibility research

Xtrusio is the Perception Engine for B2B brands.

Free check

See how AI engines answer about you

Get your free AI visibility check

Talk to us about the managed plan (free trial)