is OpenAI’s coding agent, and it comes in several shapes: an editor extension, a desktop app, a cloud version you reach through ChatGPT. This course is about one of them, Codex CLI, the agent that runs in your terminal. Everything here applies to that one.
What the install actually does
It puts one program, codex, into a folder that your shell searches when you type a command name. That list of folders is your .
The program does not watch your files in the background. It starts when you type codex, works in the folder you started it from, and stops when you close it.
Install it
These commands come from the official Codex CLI page and the project README. If one ever stops working, those two are the ones to trust.
macOS or Linux — the standalone installer:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Windows — open a new PowerShell window and run:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
With a package manager, if you already use one:
npm install -g @openai/codex
brew install --cask codex
The -g in the command means global: install it as a program for your whole user, not as a library inside one project.
Updating is the same move as installing. Run the installer script again, or the same npm install -g command; with Homebrew it is brew upgrade --cask codex.
Then open a new terminal window and check it worked:
codex --version
A version number means you are done. command not found (or “not recognized” on Windows) almost always means the terminal you are in was opened before the install added its folder to your PATH. A new window fixes that more often than anything else.
Try the PATH idea for yourself
Run echo $PATH below to see the folders your shell searches, then install Codex the npm way. The simulator does not run the real agent, but the install command is the real one.
Quick check
You install Codex in one terminal window and type codex in a window that was already open. It says command not found. What do you try first?
The first run: signing in
The model does not run on your machine; it runs on OpenAI’s side, so the first time you start codex it needs to know who you are. Open a project folder, run codex, and pick one of two answers.
Sign in with ChatGPT. Codex opens a browser window, you sign in there, and the browser hands the credentials back to the terminal. OpenAI recommends this route if you have a ChatGPT plan that includes Codex — the README names Plus, Pro, Business, Edu and Enterprise. What each plan includes changes over time, so check OpenAI’s Codex in ChatGPT page rather than trusting a list in a course.
Sign in with an API key. Usage is then billed through your OpenAI Platform account at API rates, and some features that depend on a ChatGPT workspace or the cloud side are limited. The key travels through a pipe from an environment variable, so the key itself is never part of a command you type:
printenv OPENAI_API_KEY | codex login --with-api-key
Keys are passwords
An is a password with a bill attached. Keep it in an or a that Git ignores, never in a source file, and never in a commit.
Three commands for day one
codex login status tells you how you are signed in right now. When something behaves as if you are on the wrong account, start there.
codex logout clears the cached login. Codex keeps it in ~/.codex/auth.json or in your operating system’s credential store, and reuses it every session, so you do not sign in daily.
codex --help lists everything else. Reading --help before a tutorial is a habit that will outlast every command in this lesson.
Do I need a paid plan to use Codex CLI?
You need either a ChatGPT plan that includes Codex, or an OpenAI API key billed at API rates. OpenAI recommends signing in with ChatGPT and lists the plans that include Codex on its help page, which is the place to check what yours covers today. The lessons on this site run in a browser simulator and need neither.
Should I install with the script, npm or Homebrew?
Any of them gives you the same codex command. The standalone script is the one the Codex docs lead with and needs nothing else installed. Use npm or Homebrew if you already manage your tools that way, and update Codex the same way you installed it.