How to install Codex

Install OpenAI's Codex coding agent: npm or installer script, the package name mistake everyone makes, sign-in options, and the CLI, IDE, and app surfaces.

Codex is OpenAI's coding agent. It runs locally, reads and changes code in a directory you choose, executes commands, and ships work end to end. It comes as a CLI, an IDE extension, and inside the ChatGPT apps; this guide covers the local install.

Prerequisites

  • For the npm path: Node.js 22 or later. Earlier versions fail or misbehave.
  • A ChatGPT plan that includes Codex (Plus, Pro, Business, Edu, or Enterprise), or an OpenAI API key.

Install

npm (most common):

npm install -g @openai/codex

The classic mistake: npm i -g codex installs an unrelated package from 2012. The OpenAI agent is the scoped package, @openai/codex.

Installer script, macOS / Linux:

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

Windows:

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

Homebrew also works: brew install codex.

Sign in and run

cd /path/to/your/project
codex

On first run you'll be prompted to sign in with your ChatGPT account (recommended; usage comes out of your plan) or an API key. After that, describe what you want and Codex plans, edits, and runs code in the selected directory, asking for approval based on your configured autonomy level.

Where Codex runs

  • CLI: the codex command, the most scriptable surface.
  • IDE extension: the same agent inside VS Code and Cursor.
  • ChatGPT app: cloud tasks from the Codex tab, including delegating work from your phone.

The local CLI and the cloud tasks share your ChatGPT account, so you can hand work between them.

Next steps

Sources: Codex quickstart and Codex CLI reference, checked June 2026.

Share: