Install Codex CLI and Sign In

Install Codex CLI with an official standalone, npm, or Homebrew method; verify the command, sign in safely, and troubleshoot PATH and headless-login failures.

Updated · Markdown version

Short answer

Checked 2026-11-25: the openai/codex README lists standalone scripts for macOS/Linux and Windows, plus npm and Homebrew installation commands. Choose one method for which its prerequisite—PowerShell, curl and a shell, npm, or Homebrew—is already available. Confirm it with codex --version, then run codex in a project folder and choose "Sign in with ChatGPT", or pipe an API key into codex login --with-api-key. Run codex login status to see which method is active.

Before you start

The supplied README does not provide a complete system-requirements matrix. It does show method-specific prerequisites: npm for the npm command, Homebrew for the cask, curl plus a shell for the macOS/Linux script, or PowerShell for the Windows script. Confirm current platform requirements in the official documentation before installing. You need either a ChatGPT account on a plan that includes Codex (the README recommends ChatGPT sign-in for Plus, Pro, Business, Edu and Enterprise) or an OpenAI API key. Read Codex Pricing and Usage Limits: How Metering Works first if the billing difference matters to you.

Install the CLI

Pick one method. They all install the same tool.

MethodCommandPlatform
npmnpm install -g @openai/codexRequires an npm/Node environment; consult current support documentation for platform requirements
Homebrewbrew install --cask codexmacOS (Homebrew cask)
Script (macOS, Linux)the install.sh command belowmacOS, Linux
Script (Windows)the install.ps1 command belowWindows

The two script commands from the README are:

curl -fsSL https://chatgpt.com/codex/install.sh | sh
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
  1. Choose a method and run it in a terminal.
  2. If you prefer to read a script before running it, download it first, then read and run it:
curl -fsSL https://chatgpt.com/codex/install.sh -o install-codex.sh
sh install-codex.sh
  1. Open a new terminal window so the shell picks up any PATH change.
  2. Check the install:
codex --version

Check that the command reports the installed CLI version. A local Windows check on 2026-11-25 launched the installed CLI entry point through Node with --version, exited successfully and printed codex-cli 0.161.0; the version number and formatting may differ with your installation. This checks that the executable runs, not that authentication or a coding task works. If the command is not found, go to the troubleshooting section below.

The README also describes where the standalone installers get the binary: from releases.openai.com/codex by default, with a fallback to GitHub Releases. Setting CODEX_INSTALLER_USE_RELEASES_OPENAI_COM to false (the page also accepts 0 and no) forces GitHub Releases, which helps if the first host is blocked on your network.

Manual binary download

The README lists these archives on the latest GitHub Release: codex-aarch64-apple-darwin.tar.gz (macOS Apple Silicon), codex-x86_64-apple-darwin.tar.gz (macOS Intel), codex-x86_64-unknown-linux-musl.tar.gz (Linux x86_64) and codex-aarch64-unknown-linux-musl.tar.gz (Linux arm64). Each archive holds one file with the platform in its name; extract it and rename it to codex, then put it on your PATH.

Sign in

Start Codex from the project folder you want it to work in:

codex

On first run it asks how to sign in. Two methods are documented on OpenAI's auth page.

Sign in with ChatGPT

  1. Choose "Sign in with ChatGPT" and finish the browser flow. codex login starts the same browser flow from the command line.
  2. On a machine without a browser, run codex login --device-auth. OpenAI labels this beta. First enable device code login in your ChatGPT security settings (personal accounts) or in workspace permissions (admins). Then open the link it prints and enter the one-time code.

Sign in with an API key

  1. Put the key in the OPENAI_API_KEY environment variable.
  2. On macOS or Linux, use the documented stdin example:
printenv OPENAI_API_KEY | codex login --with-api-key

The supplied source does not provide a PowerShell equivalent. Windows readers should follow the current official authentication instructions rather than substituting an unverified command.

The page also documents printenv CODEX_ACCESS_TOKEN | codex login --with-access-token for enterprise automation. Keep keys in the variable, not typed inline in the command, so they stay out of shell history.

ChatGPT sign-in versus API key

ChatGPT sign-inAPI key
BillingIncluded ChatGPT plan creditsStandard API pricing on your OpenAI Platform account
Codex cloudSupported (required)Not available
PluginsAvailability depends on the plugin, plan and workspace settingsSupported OpenAI-curated plugins only
Data handlingChatGPT workspace permissions and Enterprise settingsThe API organization's retention and sharing settings

OpenAI recommends API keys for programmatic CI/CD use, and advises against running Codex in untrusted or public environments.

Check that it worked

  1. Run codex login status. It prints the active method.
  2. Run codex in a project folder. It should reach the prompt without asking you to sign in again.
  3. If either check fails, record the exact error and consult the current official CLI documentation. No additional diagnostic command was verified for this guide.

Where your login is stored

OpenAI's auth page says Codex caches login details in ~/.codex/auth.json or in the OS credential store, depending on the cli_auth_credentials_store setting in config.toml:

# file | keyring | auto | ephemeral
cli_auth_credentials_store = "keyring"

file writes auth.json under CODEX_HOME (default ~/.codex), keyring uses the OS store and fails if it is unavailable, auto tries the OS store and falls back to the file, and ephemeral keeps credentials in memory for the current process only. The page says to treat auth.json as a secret because it contains access tokens. The CLI and the IDE extension share cached login details, so logging out of one means signing in again in the other.

Update, sign out and uninstall

  • Update: The supplied official CLI page documents updating a standalone installation by running its install script again. It does not provide package-manager update instructions in the supplied text.
  • Sign out: codex logout clears the current cached credentials according to the authentication page.
  • Uninstall: No verified uninstall procedure is present in the supplied sources. Consult the current official documentation or the package manager used to install it. Do not delete ~/.codex merely to uninstall the executable: that directory can contain configuration and file-based credentials, while credentials may instead be in the OS keyring.

What goes wrong and how to fix it

  1. `codex: command not found` after an npm install. Cause: the npm global folder is not on PATH, or the terminal was open before the install. Fix: open a new terminal, then check where the shell looks. On macOS and Linux run which codex. In Windows PowerShell, use Get-Command codex; bare where is normally a PowerShell alias rather than the Windows executable locator. No local command-location result was recorded for this guide. If nothing prints, add your npm global bin folder to PATH (npm config get prefix shows its base).
  2. The script ran but the command is missing. Cause: the installer put the binary in a folder not on PATH, or the terminal was not restarted. Fix: restart the terminal and check codex --version. The README does not state the install folder, so look at the installer's own output.
  3. The download host is blocked. Cause: a firewall or proxy blocks releases.openai.com. Fix: set CODEX_INSTALLER_USE_RELEASES_OPENAI_COM=false to use GitHub Releases, or use the manual archive.
  4. Windows: Codex cannot run shell commands. Issue #2892 reported program not found with Codex CLI 0.27.0 on Windows and was closed as completed on 2025-11-25. The supplied issue record does not contain its comments, a confirmed cause, or a supported workaround. Record your current version and exact error, update through a documented method, and use current Windows troubleshooting guidance rather than assuming this historical report has the same cause.
  5. Login cannot open a browser on a remote machine. Fix, in OpenAI's order: use codex login --device-auth. If that fails, copy ~/.codex/auth.json from a machine where you logged in (scp ~/.codex/auth.json user@remote:~/.codex/auth.json after ssh user@remote 'mkdir -p ~/.codex'), which does not apply if your OS uses a keyring. Or forward the callback port with ssh -L 1455:localhost:1455 user@remote, run codex login in that session, and open the printed address locally.
  6. Device code option is missing or rejected. Cause: device code login is not enabled for your account or workspace. Fix: enable it in ChatGPT security settings or workspace permissions.
  7. Unexpected bill. Cause: you signed in with an API key and expected plan credits. Fix: run codex login status, and sign in with ChatGPT if you want plan billing.
  8. `codex login` refused. The auth page says Codex rejects codex login and codex logout when the process selects workload identity. Fix: use that environment's configured identity instead.

What our catalogue shows

The supplied catalogue has no Codex-installation skill record. Its entries labelled install_verifications are narrow Claude Code routing probes that asked the model to identify a skill and stop; they do not establish skill installation, task completion, Codex compatibility, or efficacy. The listed skills are therefore contextual follow-up resources, not verified parts of this installation procedure.

SkillStored Platform Score and stateStored efficacy verdictClaude Code routing probeTutorial video record
agent-instruction-files46, provisionalNo verdict recordedClaude Code 2.1.330, 2026-11-23yes
skill-authoring-and-evals62, ratedLIFT_UNCONFIRMED (measured, 2026-11-22)Claude Code 2.1.330, 2026-11-23yes
openai-docsNot yet scored (checked 2026-11-27)No verdict recordedClaude Code 2.1.330, 2026-11-23no
skill-installer (openai)Not yet scored (checked 2026-11-27)No verdict recordedClaude Code 2.1.330, 2026-11-23yes

After the install, Codex Skills Explained: Locations and AGENTS.md Differences explains the bundled skill-installer and openai-docs. The catalogue's Platform Score methodology explains the score column.

FAQ

What is the command to install Codex CLI?

The README gives npm install -g @openai/codex, brew install --cask codex, curl -fsSL https://chatgpt.com/codex/install.sh | sh for macOS and Linux, and a PowerShell script from chatgpt.com/codex/install.ps1 for Windows. Pick one; they install the same CLI.

How do I check which version of Codex I have?

Run codex --version. Check the reported installed version. The Windows diagnostic described above checked the executable only; it did not test authentication or complete a coding task. Run the command again after updating and compare the output.

Can I use Codex with an API key instead of a ChatGPT account?

Yes. Run printenv OPENAI_API_KEY | codex login --with-api-key. Usage then bills at standard API pricing, Codex cloud is not available, and some workspace features are limited.

How do I sign in on a server with no browser?

Use codex login --device-auth, which OpenAI marks beta. Enable device code login in your ChatGPT settings first. If it still fails, OpenAI documents copying auth.json or forwarding port 1455 over SSH.

Where does Codex store my login?

In ~/.codex/auth.json or the OS credential store, depending on cli_auth_credentials_store. Treat auth.json like a password.

How do I update Codex?

For a standalone installation, the supplied official CLI page says to run the install script again. The supplied sources do not verify a separate update subcommand or package-manager update procedure.

How do I install Codex on Windows?

Use the PowerShell script, or npm if you already have Node. The CLI page links to separate Windows and WSL pages, so check them for the setup you want.

Next steps

Platform Score is our assessment under a published method. It is not a safety guarantee.

Next steps

  1. Codex Skills Explained: Locations and AGENTS.md Differences Read next.
  2. Codex AGENTS.md setup: file locations and layering Read next.
  3. Codex compatibility Install evidence per tool.
  4. All guides by topic Browse everything.

Sources