Get featured

How to install the Codex CLI and run your first task

Guide · checked against the docs on

OpenAI describes it this way: "Codex CLI is a coding agent from OpenAI that runs locally on your computer." This guide covers installing it, signing in, choosing how much it's allowed to do, and giving it a first small task. Everything here is quoted from OpenAI's Codex GitHub README, the CLI quickstart, and the sign-in, security and Windows pages, checked Oct 2026.

Not affiliated with or endorsed by OpenAI. Check OpenAI's current docs before relying on these details.

Our tool page: OpenAI Codex

What you need first

The repo's install notes list "macOS 12+, Ubuntu 20.04+/Debian 10+, or Windows 11 via WSL2", "4-GB minimum (8-GB recommended)" of RAM, and Git "2.23+ for built-in PR helpers" (optional but recommended).

A note on Windows: those same install notes say WSL2, but the README and OpenAI's Windows page now also offer a native Windows installer: "Use Codex on Windows with the native ChatGPT desktop app, the CLI, or the IDE extension." If you're on Windows, read that page first to choose.

You also need a way to sign in, either a ChatGPT plan or an API key (see Step 3). For prices, see Codex pricing (checked Oct 2026).

Step 1: Install

macOS or Linux:

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

Windows (PowerShell):

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

These commands download a script and run it right away, and the Windows one also bypasses PowerShell's script policy for that one run. If you want to see what it does first, open the script's address in your browser and read it before you run the command.

Or use a package manager. The README says "Codex CLI can also be installed via the following package managers":

npm install -g @openai/codex
brew install --cask codex

You can also download a ready-made binary from the latest GitHub release. The README notes "you likely want to rename it to codex after extracting it."

The current version was 0.162.1 when we checked (Oct 2026). It changes often.

Step 2: Updating and removing it

If you used the curl installer, OpenAI's quickstart says to update by running the same command again:

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

OpenAI's docs don't give update or uninstall steps for npm or Homebrew, so check those tools' own docs. If you remove it, know that your sign-in and settings live in the ~/.codex folder. Homebrew's cask record for Codex removes that folder as part of its full-cleanup ("zap") step.

Step 3: Sign in

Go to your project folder and start Codex:

cd /path/to/your/project
codex

The README says: "Run codex and select Sign in with ChatGPT. We recommend signing into your ChatGPT account to use Codex as part of your Plus, Pro, Business, Edu, or Enterprise plan." You can also run codex login and "complete the browser flow."

To use an API key instead, which is "usage-based access", the sign-in page gives:

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

Keep your sign-in file private. OpenAI warns: "treat ~/.codex/auth.json like a password: it contains access tokens. Don't commit it, paste it into tickets, or share it in chat." For more on this, see our keeping secrets safe with AI coding tools guide.

Step 4: Choose how much it can do

OpenAI's security page says "By default, the agent runs with network access turned off," and Codex uses "an OS-enforced sandbox that limits what it can touch (typically to the current workspace), plus an approval policy that controls when it must stop and ask you before acting."

For a first look where it can't change anything, the docs give:

codex --sandbox read-only --ask-for-approval on-request

In the "Auto preset" (--sandbox workspace-write --ask-for-approval on-request), "Codex can read files, make edits, and run commands in the working directory automatically," and it asks before editing outside the workspace or using the network.

There's also a full-access mode. The docs say "Use caution before doing so." Don't use it while you're learning.

Step 5: Your first task

The quickstart says to "describe what you want to accomplish," for example to "ask Codex to explain the project, make a focused change, or help debug an issue." Here is OpenAI's example prompt (we haven't tried it ourselves):

Tell me about this project

Then try one small, focused change and read what it did before you keep it. OpenAI's own tip: "Create Git checkpoints before and after a task so you can revert changes."

Next steps

Not affiliated with or endorsed by OpenAI. Check OpenAI's current docs before relying on these details.