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.
| Method | Command | Platform |
|---|---|---|
| npm | npm install -g @openai/codex | Requires an npm/Node environment; consult current support documentation for platform requirements |
| Homebrew | brew install --cask codex | macOS (Homebrew cask) |
| Script (macOS, Linux) | the install.sh command below | macOS, Linux |
| Script (Windows) | the install.ps1 command below | Windows |
The two script commands from the README are:
curl -fsSL https://chatgpt.com/codex/install.sh | shpowershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"- Choose a method and run it in a terminal.
- 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- Open a new terminal window so the shell picks up any PATH change.
- Check the install:
codex --versionCheck 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:
codexOn first run it asks how to sign in. Two methods are documented on OpenAI's auth page.
Sign in with ChatGPT
- Choose "Sign in with ChatGPT" and finish the browser flow.
codex loginstarts the same browser flow from the command line. - 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
- Put the key in the
OPENAI_API_KEYenvironment variable. - On macOS or Linux, use the documented stdin example:
printenv OPENAI_API_KEY | codex login --with-api-keyThe 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-in | API key | |
|---|---|---|
| Billing | Included ChatGPT plan credits | Standard API pricing on your OpenAI Platform account |
| Codex cloud | Supported (required) | Not available |
| Plugins | Availability depends on the plugin, plan and workspace settings | Supported OpenAI-curated plugins only |
| Data handling | ChatGPT workspace permissions and Enterprise settings | The 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
- Run
codex login status. It prints the active method. - Run
codexin a project folder. It should reach the prompt without asking you to sign in again. - 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 logoutclears 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
~/.codexmerely 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
- `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, useGet-Command codex; barewhereis 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 prefixshows its base). - 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. - The download host is blocked. Cause: a firewall or proxy blocks
releases.openai.com. Fix: setCODEX_INSTALLER_USE_RELEASES_OPENAI_COM=falseto use GitHub Releases, or use the manual archive. - Windows: Codex cannot run shell commands. Issue #2892 reported
program not foundwith 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. - 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.jsonfrom a machine where you logged in (scp ~/.codex/auth.json user@remote:~/.codex/auth.jsonafterssh user@remote 'mkdir -p ~/.codex'), which does not apply if your OS uses a keyring. Or forward the callback port withssh -L 1455:localhost:1455 user@remote, runcodex loginin that session, and open the printed address locally. - 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.
- 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. - `codex login` refused. The auth page says Codex rejects
codex loginandcodex logoutwhen 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.
| Skill | Stored Platform Score and state | Stored efficacy verdict | Claude Code routing probe | Tutorial video record |
|---|---|---|---|---|
| agent-instruction-files | 46, provisional | No verdict recorded | Claude Code 2.1.330, 2026-11-23 | yes |
| skill-authoring-and-evals | 62, rated | LIFT_UNCONFIRMED (measured, 2026-11-22) | Claude Code 2.1.330, 2026-11-23 | yes |
| openai-docs | Not yet scored (checked 2026-11-27) | No verdict recorded | Claude Code 2.1.330, 2026-11-23 | no |
| skill-installer (openai) | Not yet scored (checked 2026-11-27) | No verdict recorded | Claude Code 2.1.330, 2026-11-23 | yes |
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
- What Is OpenAI Codex? Surfaces and Their Uses to see where the CLI fits among the app, IDE and cloud.
- Codex AGENTS.md setup: file locations and layering to give Codex project rules.
- Codex Skills Explained: Locations and AGENTS.md Differences to add skills.
- Codex vs Claude Code: Config Files and Sandbox if you are choosing between them.
- See the Codex tool page and the agent workflow topic.
Related skills in this catalog
Platform Score is our assessment under a published method. It is not a safety guarantee.
Related guides
- Codex Skills Explained: Locations and AGENTS.md Differences
- Codex AGENTS.md setup: file locations and layering
- Codex vs Claude Code: Config Files and Sandbox
- Codex Pricing and Usage Limits: How Metering Works
- What Is OpenAI Codex? Surfaces and Their Uses
- Install Claude Code: Native, Homebrew, WinGet, or npm
Sources
- https://github.com/openai/codex (accessed 2026-11-27)
- https://learn.chatgpt.com/docs/auth (accessed 2026-11-27)
- https://learn.chatgpt.com/docs/codex/cli (accessed 2026-11-27)
- https://github.com/openai/codex/issues/2892 (accessed 2026-11-27)