Install the Codex CLI

Install the Codex CLI with OpenAI's standalone installer. On macOS or Linux, run curl -fsSL https://chatgpt.com/codex/install.sh | sh. On Windows, run the install.ps1 command from a new PowerShell window. Alternatives are npm install -g @openai/codex or brew install --cask codex. Then run codex in a project folder and choose Sign in with ChatGPT.

Applies to: Codex CLI, macOS, Linux, Windows

1. Install

Pick one method.

macOS or Linux: standalone installer

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

Windows: standalone installer

Start a new PowerShell window, then run:

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

npm (any OS with Node.js)

npm install -g @openai/codex

Homebrew (macOS)

brew install --cask codex

According to the README, the standalone installers download from releases.openai.com/codex and fall back to GitHub Releases if that’s unavailable. To force GitHub Releases:

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

2. Confirm it installed

Open a new terminal so your PATH refreshes, then run:

codex --version

You should see a version number. If you see “command not found”, follow this fix.

3. Sign in

Go to a project folder and start Codex:

cd path/to/your/project
codex

Choose Sign in with ChatGPT. Your browser opens, and after you sign in it hands the credentials back to the CLI. You can also run codex login directly. To use an API key instead:

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

Check which method is active with codex login status. Working over SSH or on a headless server? Use codex login --device-auth. More sign-in options.

4. Run a first prompt

Tell me about this project

Then continue with your first real task.

Useful commands to know

CommandWhat it does
codexStart an interactive session in the current folder
codex resumeReopen a recent chat from this repository
codex exec "..."Run non-interactively, for scripts and CI
codex --searchUse live web search for this run
codex mcp add ...Connect an MCP server
codex login statusShow the active sign-in method
codex completionGenerate shell completions

Questions people ask

Which install method should I use?

The standalone installer is the method OpenAI lists first, and it doesn't need Node.js. Use npm or Homebrew if you already manage your tools with them. Avoid mixing methods, or you may end up with two copies on your PATH.

Can I force the installer to download from GitHub?

Yes. The README says setting CODEX_INSTALLER_USE_RELEASES_OPENAI_COM=false makes the installer use GitHub Releases instead of releases.openai.com.

How do I see what Codex is doing for debugging?

Run codex -c log_dir=./.codex-log to write a plaintext log, then follow it with tail -F ./.codex-log/codex-tui.log.

Sources

We link to the official source for every instruction on this page. If anything here disagrees with them, trust the official source and tell us.