Install the Codex CLI: the installer, npm, or Homebrew

Installation takes about a minute. The two things worth getting right on the first run are which account it bills to and which sandbox it starts in, and there is now a single command that checks both for you.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

The official route is curl -fsSL https://chatgpt.com/codex/install.sh | sh on macOS and Linux, or the PowerShell one-liner on Windows. npm install -g @openai/codex and brew install --cask codex both work too. Run codex in a repository, sign in with your ChatGPT account to bill against your subscription, then run codex doctor to confirm the install, config, auth, and sandbox are all healthy.

What you need to know
  • One command: curl -fsSL https://chatgpt.com/codex/install.sh | sh. No Node needed.
  • npm i -g @openai/codex and brew install --cask codex are the alternatives.
  • Sign in with ChatGPT to use your subscription. An OPENAI_API_KEY silently overrides it.
  • codex doctor checks install, config, auth, and runtime in one shot. Run it first when anything is wrong.
  • Launch from the repository root: the working directory is the sandbox scope.
  • Defaults as of August 2026: model gpt-5.6-sol, effort low, sandbox workspace-write.

Pick an install route

There are three, and they differ mainly in what breaks them later.

macOS and Linux. The official installer is the shortest path.
# official installer, self-contained, no Node
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# or Homebrew
brew install --cask codex

# or npm, if you already manage global CLIs that way
npm install -g @openai/codex

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

codex --version

What each route costs you later.

RouteNeeds Node?Update withBreaks when
Official installerNocodex updateRarely
Homebrew caskNobrew upgrade --cask codexRarely
npm globalYes, 16+npm update -g @openai/codexYou change Node version

If npm fails with EACCES

Never fix this with sudo. Installing globally as root leaves root-owned files under your npm prefix, and every later install for your user fails in a way that is much harder to diagnose than the original error.

Give npm a prefix your user owns, then reinstall.
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
source ~/.zshrc

npm install -g @openai/codex
codex --version

If you have already run a sudo install, remove the root-owned tree before retrying, or the reinstall inherits the same problem.

First run and signing in

01

Start it in the repository root

cd ~/code/your-project
codex

The directory you launch from becomes the workspace root, and the sandbox is scoped to it. This is not a convention, it is the boundary. Outside a git repository Codex refuses to start unless you pass --skip-git-repo-check, which is a deliberate guard rather than a bug.

02

Choose ChatGPT, not an API key

The first run offers both. Signing in with ChatGPT uses the subscription you already pay for and costs nothing extra. Choosing an API key bills per token from the very first message.

codex login           # opens a browser
codex login status    # what am I actually signed in as?
03

Check nothing is overriding it

echo $OPENAI_API_KEY   # should be empty for subscription billing

A key exported months ago for an unrelated script takes precedence over the subscription login. That is the single most expensive mistake on this page: you pay the subscription and the metered bill at the same time, and nothing warns you.

04

Verify the whole install in one command

codex doctor

It diagnoses the local installation, the config file, authentication, and runtime health together. When something is wrong later, this is the first thing to run and the first thing to paste into a bug report.

What to set on day one

Codex works out of the box. These are the four settings worth a deliberate decision before you build habits around the defaults.

~/.codex/config.toml
# Sensible defaults for interactive work.
model                  = "gpt-5.6-sol"    # sol | terra | luna
model_reasoning_effort = "low"           # sol is strong at low; escalate on evidence

# Can edit inside the workspace, asks before anything outside it.
sandbox_mode    = "workspace-write"
approval_policy = "on-request"

# Network is OFF in workspace-write unless you say otherwise.
[sandbox_workspace_write]
network_access = false

Two orthogonal settings that almost everyone conflates.

SettingControlsEnforced by
sandbox_modeWhat Codex is capable of touchingThe operating system
approval_policyWhen it asks you firstThe agent loop

What lives in ~/.codex after a first run.

PathHolds
config.tomlEvery setting
auth.jsonCredentials. Never commit this.
sessions/JSONL transcript of every run
history.jsonlPrompt history for recall
log/Diagnostics codex doctor reads
<name>.config.tomlA named profile, loaded with -p <name>

Confirming which Codex you are actually running

It is easy to end up with two or three installs: the official installer in one place, an npm global from six months ago in another, and a Homebrew cask on top. They do not conflict loudly. They just mean the version you upgraded is not the one your shell runs, and every symptom after that is confusing.

Two commands that settle it.
which -a codex     # every codex on PATH, in the order the shell picks them
codex --version    # the one that actually wins

What a duplicate install looks like.

SymptomWhat is happening
Upgraded, version unchangedA second install earlier on PATH
A flag from the changelog is unrecognisedYou are on an older binary than you think
Works in one terminal, not anotherDifferent PATH, usually a login shell versus a tool shell

When it will not run

Ranked by how often it is actually the cause.

SymptomCauseFix
codex: command not foundPATH not reloadedOpen a new shell
Vanished after a Node upgradenpm global prefix movedReinstall, or switch to the installer
Billed per token unexpectedlyOPENAI_API_KEY is setunset OPENAI_API_KEY, then codex login
Login never completesNo browser, or a proxyCopy the URL manually, or use --with-api-key
Refuses to start in a folderNot a git repositorygit init, or --skip-git-repo-check
Cannot write filesSandbox is read-onlycodex -s workspace-write
npm install fails inside a sessionSandbox blocks network by designEnable network_access deliberately
Anything elseUnknowncodex doctor before anything else
What a working install looks like from outside the terminal: quota as a gauge you can see filling, rather than a limit message you discover.

Questions people ask

Run curl -fsSL https://chatgpt.com/codex/install.sh | sh on macOS or Linux, or the PowerShell one-liner from chatgpt.com/codex/install.ps1 on Windows. brew install --cask codex and npm install -g @openai/codex also work. Then run codex in a project directory and sign in with ChatGPT.

Only for the npm route, which declares node 16 or newer. The official installer and the Homebrew cask ship a self-contained platform binary and need no Node at all.

No. Signing in with a paid ChatGPT account uses your subscription. A key is for CI, servers, and metered billing with no usage windows.

Because OPENAI_API_KEY is set in your environment and takes precedence over the subscription login. Unset it and run codex login again, then confirm with codex login status.

In ~/.codex/: config.toml for settings, auth.json for credentials, sessions/ for the JSONL transcript of every run, and one file per named profile, such as build.config.toml.

The sandbox is probably read-only. Pass -s workspace-write for one run, or set sandbox_mode = "workspace-write" in config.toml.

Yes, with --skip-git-repo-check. The check exists because git is the undo button for an agent that edits files, so removing it is a deliberate choice rather than a convenience.

codex doctor. It diagnoses the installation, config, auth, and runtime together, which is faster than guessing and is what a maintainer will ask for anyway.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. OpenAI Codex documentation
  2. openai/codex on GitHub
Try it

Codex and Claude,
one workbench.

Continuum drives both under your own subscriptions, with live quota gauges and spend by repo.

free app · your subscriptions · local-first