LevelUpWith

Explore / Codex in Practice: Delegate, Review and Ship / Lesson 2

Lesson 2: Install Codex and Sign In

Install the Codex CLI and the IDE extension, sign in with a ChatGPT account or an API key, and run a first session in the practice repository.

Free to read, no account needed. Part of Codex in Practice: Delegate, Review and Ship.

By the end of this level you'll be able to

  • Install the Codex CLI and the IDE extension, then check that the installed version matches the current release notes
  • Sign in with a ChatGPT account or an API key, and explain how the two differ in billing and in where your credentials are stored
  • Start Codex in the practice repository and confirm that it can read the project

Why setup matters more than it looks

In Level 1 you met the different forms of Codex. Now you'll put two of them on your machine: the CLI, which runs in your terminal, and the IDE extension, which runs inside your editor. Think of this level as setting up a new team member's laptop. You want the right version, the right account and a quick test in a real repository before you trust them with anything.

The one decision here that you'll live with is how you sign in. That choice decides who pays for the work and where your credentials are kept, so we'll take it slowly.

Step 1: Install the CLI

OpenAI now offers a standalone installer as well as the usual package managers. Pick one method:

# macOS / Linux: the official install script
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# Or with a package manager you already use
npm install -g @openai/codex      # needs Node.js
brew install --cask codex         # macOS, Homebrew
# Windows (PowerShell): native installer
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

Codex now runs natively on Windows in PowerShell, using its own Windows sandbox. You only need WSL2 if your tools and repositories already live in Linux. In that case, install Codex inside WSL and keep the repository on the Linux filesystem (~/code/...), not under /mnt/c/, where file access is slow.

Gotcha: two installs. If you install with npm and with brew or the script, your shell runs whichever copy comes first on your PATH. Then you upgrade one copy and wonder why nothing changed. Run which codex (or Get-Command codex in PowerShell) to see which copy you're running.

Step 2: Check the version against the release notes

Codex ships new versions often, often weekly, so "I installed it" is not the same as "I'm current".

codex --version
# example output: codex-cli 0.163.0

Now open the project's releases page at github.com/openai/codex/releases/latest. Release tags look like rust-v0.163.0. Compare the number after the v with your output. If yours is older, upgrade the same way you installed: run the script again, or use npm install -g @openai/codex@latest or brew upgrade --cask codex.

Why bother? Commands and flags change from release to release. When a tutorial, or this course, shows a flag your copy doesn't recognise, an out-of-date version is the first thing to check.

Step 3: Install the IDE extension

In VS Code, open the Extensions sidebar and search for ChatGPT, published by OpenAI (its ID is openai.chatgpt). The same extension works in VS Code-compatible editors such as Cursor and Windsurf. JetBrains IDEs and Xcode have their own integrations instead.

Once it's installed, click the Codex icon in the activity bar. If you can't see it, open the Command Palette (Ctrl+Shift+P) and run Codex: Open Codex Sidebar.

Tip: Check the publisher before you install. The marketplace has plenty of look-alike "Codex" and "GPT" extensions from other publishers.

Step 4: Sign in, and understand what you're choosing

You have two options:

Sign in with ChatGPT Sign in with API key
Who pays Your ChatGPT plan's included usage Your OpenAI Platform account, billed per token at standard API rates
Governed by Your ChatGPT workspace's permissions and admin settings Your Platform org and project
Features Full set, including features that depend on your ChatGPT workspace or on cloud services Local workflows work; some workspace and cloud features are limited or unavailable
Good for Daily interactive work Automation, CI, or teams that budget through the API
codex login                     # opens a browser to sign in with ChatGPT
codex login --device-auth       # no browser on this machine (SSH, remote box): use a device code

# API key: pipe it in on stdin so it doesn't end up in your shell history
printenv OPENAI_API_KEY | codex login --with-api-key
# PowerShell equivalent:
# $env:OPENAI_API_KEY | codex login --with-api-key

codex login status              # which method is active right now?
codex logout                    # clear the cached credentials

In the IDE extension, the signed-out screen offers the same choice. Pick Use API Key if you want key-based billing.

Where the credentials are stored. Codex caches your login so you don't have to sign in every session. Depending on a setting called cli_auth_credentials_store, it uses a file (~/.codex/auth.json), your operating system's keyring, or auto, which tries the keyring first and falls back to the file. We'll cover the configuration file properly in Level 5. For now, the rule is: if auth.json exists, treat it like a password. Never commit it, never copy it into a container image and never paste it into a chat.

The CLI and the extension share the same cached login. If you sign out of one, you're signed out of both. That's handy, and it also explains why the extension sometimes suddenly asks you to sign in again.

Pitfall: If you sign in with ChatGPT and also have OPENAI_API_KEY exported for other tools, run codex login status to confirm which method Codex is actually using before you assume where the bill goes.

Step 5: First session in the practice repository

cd ~/code/practice-repo     # always start Codex from the repository root
codex                       # opens the interactive session

If Codex asks a first-run question about the folder, read it before you answer. Approvals and sandboxing come later in the course. For your first prompt, ask for something read-only, so nothing can go wrong:

Without changing any files, list the top-level folders in this repository,
say which language and test framework it uses, and name the file you
would read first to understand it.

You should get an answer that names real files from your repository, such as package.json and src/, and the test runner it found. Check them against ls yourself. Made-up file names, or "I can't see any files", usually mean you started Codex in the wrong directory.

Then ask the same question in the IDE sidebar with the repository open. The two answers should broadly agree.

Your task and how to check it

  1. codex --version matches the latest tag on the releases page (or is at most one release behind).
  2. codex login status reports the method you meant to choose.
  3. The read-only prompt names at least three files or folders that really exist in the practice repository, in both the CLI and the extension.
  4. git status shows no changes, which proves the session was read-only.

Key takeaways

  • Install with one method (script, npm or brew, or the PowerShell installer on Windows) and check which copy is on your PATH.
  • Compare codex --version with the GitHub releases page. Codex changes fast, and old versions miss newer flags.
  • The IDE extension is OpenAI's ChatGPT extension in the marketplace (ID openai.chatgpt). It shares its login with the CLI.
  • Signing in with ChatGPT uses your plan's included usage. An API key is billed per token through the Platform and has fewer workspace and cloud features.
  • Cached credentials go to the OS keyring or ~/.codex/auth.json. Guard that file like a password.
  • Start Codex from the repository root and make your first prompt read-only.

A 6-question knowledge check follows this lesson in the app, free and without an account.

Keep going: levels 3 and 4 are free

Create a free account to open the next two levels, save your progress and pick up where you left off. No card needed.

Next: Level 3, The Agent Loop: Read, Plan, Act, Observe.

Create a free account →See the whole course

More like this

  • Building with the OpenAI API: From Key to Production

    Go from your first API key to a small deployed service. You'll choose models, use the Responses API, get structured outputs, call functions, add built-in tools…

    Course · OpenAI · AI & Agents · Capable · 20 levels · 4 free · Professionally curated by levelupwith.com

  • ChatGPT at Work: No-Code Skills for Knowledge Workers

    Use ChatGPT safely and well in operations, marketing, HR, finance and project work. You will write structured prompts, check outputs before you rely on them, a…

    Course · OpenAI · AI & Agents · Capable · 18 levels · 4 free · Professionally curated by levelupwith.com

  • GitHub Copilot (GH-300) Exam Prep

    Learn GitHub Copilot hands-on in the editor, in the CLI and on github.com, and work through every skill in the GH-300 study guide (skills measured as of August…

    Exam prep · GH-300 · Software & Engineering · Capable · 18 levels · 4 free · Professionally curated by levelupwith.com

  • Scaling Apps Beyond the Chat Window: Part 3, Mobile Apps, Games and Growth

    Turn your first live app into a real product. Learn to choose between web and app store apps, publish a browser game, take payments safely, run and monitor a l…

    Course · Software · Software & Engineering · Capable · 24 levels · 4 free · Professionally curated by levelupwith.com

  • Scaling Apps Beyond the Chat Window: Part 2, Online, Secure and AI-Powered

    Take one small app from your GitHub repository to a public web address. You will host it on Vercel and give it a Supabase database, sign-in and file storage, w…

    Course · Software · Software & Engineering · Capable · 16 levels · 4 free · Professionally curated by levelupwith.com

  • Scaling Apps Beyond the Chat Window: Part 1, From Prompt to Project

    Move an app you built in an AI chat onto your own computer and work on it step by step with a coding agent. Save your work with Git, keep secrets out of your c…

    Course · Software · Software & Engineering · Capable · 19 levels · 4 free · Professionally curated by levelupwith.com