Install Codex CLI on a Mac or on Windows

Install OpenAI's Codex CLI with one copied command, check that it works, and sign in with your ChatGPT plan or an API key. Includes common install fixes.

Checked against official docs on 12 Oct 2026

On this page

Codex CLI is an AI assistant from OpenAI that works in the terminal. The terminal is a window where you type commands instead of clicking. Codex works on the files in one folder, inside a sandbox: a safety fence that limits what it can touch. You choose how much it may do before it asks you.

Before you start, check your account. OpenAI's plan table lists Codex CLI for ChatGPT Plus, Pro, Business, Edu and Enterprise plans, and for an OpenAI API key. An API key is a secret code that bills you for each use. The Free and Go plans list Codex in the ChatGPT desktop app, not in the CLI. Plans change, so check OpenAI's pricing page before you pay. You pay OpenAI directly.

New to the terminal? First read How to open the terminal.

Open the terminal

  • Mac: press Command + Space, type Terminal, then press Return.
  • Windows: press the Windows key, type PowerShell, then press Enter. OpenAI says to run the Windows command from a new PowerShell window.

Paste the install command

Copy the line for your computer, paste it into the terminal, then press Return or Enter.

Mac (and Linux):

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

Windows PowerShell:

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

Wait until the command finishes and the prompt comes back.

If you already use npm (a tool that installs programs) or Homebrew (an app installer for the Mac), OpenAI also gives these lines:

npm install -g @openai/codex
brew install --cask codex

Open a new terminal window

Close the window and open a new one. A new window finds programs that you installed a moment ago.

Check that it worked

codex --version

You see a version number. If you see an error instead, go to If it did not work below.

Go to a project folder

Codex works on the folder where you start it. Start in a test folder, not one with important files. Folders in the terminal shows how to make one and go into it.

Start Codex and sign in

codex

The first time, choose Sign in with ChatGPT. A browser window opens. Sign in, and the browser sends you back to Codex.

To use an API key instead, OpenAI shows this command. It reads the key from a setting called OPENAI_API_KEY:

printenv OPENAI_API_KEY | codex login --with-api-key

Next, read Your first session with Codex.

If it did not work

A parameter cannot be found that matches parameter name 'fsSL' (Windows)

You pasted the Mac command into PowerShell. In PowerShell, curl is a different program that does not accept these options. Anthropic's install help explains this same PowerShell message. Use the Windows line from above.

The terminal says codex is not found

The window was open before the install, so it does not know the new program yet. Close the window, open a new one, and type codex --version again. If it still fails, run the install line again and read its last lines for a message about the PATH (the list of folders where the terminal looks for programs).

Sign-in in the browser never finishes

This happens on a remote computer or a server without a browser. OpenAI suggests device code sign-in. First turn on device code login in your ChatGPT security settings. Then run:

codex login --device-auth

Open the link it shows on any device, sign in, and type the code.

Codex does not start after an update

OpenAI removed an old setting, approval_policy = "untrusted", and that line can stop Codex from starting. Open your Codex settings file, ~/.codex/config.toml, and delete that line. See OpenAI's approvals and security page for the safe replacement.

Sources