Codex CLI is OpenAI’s coding agent that you can run locally from your terminal. It can read, change, and run code on your machine in the selected directory. It’s open source and built in Rust for speed and efficiency. See openai/codex.
CLI setup
- 1
Install
Install the Codex CLI with npm.
npm install commandnpm i -g @openai/codex - 2
Run
Run Codex in a terminal. It can inspect your repository, edit files, and run commands.
Run Codex commandcodexThe first time you run Codex, you'll be prompted to sign in. Authenticate with your ChatGPT account or an API key.
See the pricing page if you're not sure which plans include Codex access.
- 3
Upgrade
New versions of the Codex CLI are released regularly. See the changelog for release notes. To upgrade with npm, run:
npm upgrade commandnpm i -g @openai/codex@latest
The Codex CLI is available on macOS and Linux. Windows support is experimental. For the best Windows experience, use Codex in a WSL workspace and follow our Windows setup guide.
Work with the Codex CLI
Run Codex interactively
Run codex to start an interactive terminal UI (TUI) session.
Control model and reasoning
Use /model to switch between GPT-5-Codex and GPT-5, or adjust reasoning levels.
Image inputs
Attach screenshots or design specs so Codex reads them alongside your prompt.
Run local code review
Get your code reviewed by a separate Codex agent before you commit or push your changes.
Web search
Use Codex to search the web and get up-to-date information for your task.
Codex Cloud tasks
Launch a Codex Cloud task, choose environments, and apply the resulting diffs without leaving your terminal.
Scripting Codex
Automate repeatable workflows by scripting Codex with the exec command.
Model Context Protocol
Give Codex access to additional third-party tools and context with Model Context Protocol (MCP).
Approval modes
Choose the approval mode that matches your comfort level before Codex edits or runs commands.