Primary navigation

Codex CLI

Pair with Codex in your terminal

Codex CLI

Codex CLI is a coding agent that you can run locally from your terminal and that can read, modify, and run code on your machine, in the chosen directory. It’s open-source, built in Rust for speed and efficiency, and rapidly improving at openai/codex on GitHub.

Set up

The Codex CLI officially supports macOS and Linux. Windows support is still experimental — we recommend running in WSL. See the Windows setup guide for step‑by‑step instructions.

Install Codex

You can install the Codex CLI with your preferred package manager:

Install with npm

npm install -g @openai/codex

Install with Homebrew

brew install codex

Run Codex

Then run codex to get started:

codex

The first time you run the Codex CLI, you’ll be prompted to authenticate. We recommended signing into your ChatGPT account to use Codex as part of your Plus, Pro, Team, Edu, or Enterprise plan.
You can also use Codex with an API key, but this requires additional setup. You can learn more about this and what’s included in each plan in our pricing page.

Upgrade Codex

You can upgrade Codex with your preferred package manager:

Upgrade with npm

npm install -g @openai/codex@latest

Upgrade with Homebrew

brew upgrade codex

Working with the Codex CLI

Codex runs in an interactive terminal UI. You can ask Codex to do anything, and it will read your codebase, make edits and run commands. It’s easy to guide Codex as it works with prompts, including image inputs.

Running with an input prompt

You can run Codex directly with a prompt:

codex "explain this codebase"

Models & reasoning

We recommend using Codex with GPT-5-Codex, which we’ve optimized for agentic coding in Codex. By default, Codex will run GPT-5, but you can switch to GPT-5-Codex with the /model command.

The default reasoning level is medium, and you can upgrade to high for complex tasks with the same /model command.

You can also use gpt-5-codex or older models by using API-based authentication and launching codex with the --model flag:

codex --model gpt-5-codex

You can learn more about the different models and reasoning levels in our models page.

Approval modes

We’ve chosen a powerful default for Codex works on your computer: auto.

In this approval mode, Codex can read files, make edits, and run commands in the working directory automatically. However, Codex will need your approval to work outside the working directory or access network.

When you just want to chat, or if you want to plan before diving in, you can switch to Read Only mode with the /approvals command.

If you need Codex to read files, make edits, and run commands with network access, without approval, you can use Full Access. Excercise caution before doing so.

Image inputs

You can paste images directly into the composer to attach them to your prompt. You can also attach image files via the CLI with the image flag:

codex -i screenshot.png "Explain this error"
codex --image img1.png,img2.jpg "Summarize these diagrams"

Scripting Codex

You can also run Codex non-interactively with the exec command:

codex exec "fix the CI failure"

Next steps

Since Codex CLI is an open-source project, the main docs live on the GitHub repository: github.com/openai/codex.

For more detailed docs covering advanced configuration, MCP, and more, check out the README and links in the open-source repo directly.