Skip to content
zero2vibecodelearn vibe coding
Level 0 · Install and first run 7 min Reviewed by the author · Oct 22, 2026 Verified against Codex CLI v0.163.0 · Oct 22, 2026Official docs: Codex: CLI, Auth

Installing Codex CLI and signing in

Codex CLI is one program called codex that lands in a folder your shell searches. Install it with the official script, npm or Homebrew, then sign in with your ChatGPT account or an API key the first time you run it.

Level 0 · 0 / 4 lessons0%
In this lesson

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

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.

Check your understanding

Answered 0/3
Mode:

What does installing Codex CLI put on your machine?

You want Codex to count against your ChatGPT plan rather than bill per request. How do you sign in?

Where does Codex keep your login after you sign in?

Finish the task in the terminal and answer the questions to complete the lesson.

📝 My notes

Saved automatically in this browser · shows up on the Notes page.

Task

See which folders your shell searches for programs, then install Codex CLI with npm — the one install method this simulator can run.

Tab complete · ↑ history · Ctrl+L clear · help commands

  • Not done: Print the folders your shell searches for programs
  • Not done: See a folder on your PATH
  • Not done: Install the @openai/codex package globally
  • Not done: npm reports the install

Lesson Q&A

What does installing Codex CLI put on your machine?

A program called `codex` in a folder on your PATH — The model runs on OpenAI's side. What you install is the client: a command that does nothing until you run it, in the folder you run it from.

You want Codex to count against your ChatGPT plan rather than bill per request. How do you sign in?

Run codex and choose Sign in with ChatGPT, then finish in the browser — Sign in with ChatGPT opens a browser window and hands the credentials back to Codex. An API key works too, but it is billed through the OpenAI Platform at API rates instead.

Where does Codex keep your login after you sign in?

In ~/.codex/auth.json or your operating system's credential store — The login is cached and reused across sessions. Because auth.json can be a plain-text file, treat your ~/.codex folder like any other place that holds a password.

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?

A shell reads PATH when it starts. A window opened before the install never heard about the new folder.

Commands in this lesson

Terms in this lesson

Move between lessons with ← → · search with ⌘K

Written and reviewed by Mikhail Kuzmitskii