Imagine typing a simple prompt into your terminal and watching AI whip up a full React todo app—complete with persistence and ready to run. Sounds like magic? That's the power of Codex CLI, OpenAI's command-line tool for AI-assisted coding, launched in 2025. If you're a developer who's used Claude Code, you'll love exploring Codex CLI as a fresh alternative. In this deep dive, we'll cover what Codex CLI is, how to install and use it, its standout features, and a head-to-head comparison with Claude Code, including pricing. Whether you're prototyping apps or automating tasks, Codex CLI puts Codex—OpenAI's coding-focused model—at your fingertips. Let's unpack this tool and see how it can transform your workflow!
Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?
Apidog delivers all your demands, and replaces Postman at a much more affordable price!
What Is Codex CLI and Why Use It?
Codex CLI is OpenAI's open-source command-line interface for AI-driven coding, powered by the Codex model family (like GPT-4o optimized for code). Released in mid-2025, it's designed for developers who want an interactive, terminal-based AI assistant. Unlike traditional IDE plugins, Codex CLI runs in your shell, letting you generate code, fix bugs, or build projects with natural language prompts. It's perfect for quick prototypes, like creating a React app or debugging scripts, and integrates with tools like Git for version control.

Why choose Codex CLI over something like Claude Code? It's tightly integrated with OpenAI's ecosystem, offering seamless access to models like o4-mini for efficient coding. Plus, it's free to use (beyond API costs), customizable via a config file, and supports "yolo" mode for hands-off execution. If you're building web apps, automating workflows, or experimenting with AI, Codex CLI saves time by handling boilerplate and logic. But it's not without competition—Claude Code from Anthropic offers similar features with a focus on safety. We'll compare them later. First, let's get you set up!

How to Install Codex CLI
Getting Codex CLI running is straightforward, but it varies by OS. We'll cover macOS/Linux (recommended) and Windows. The tool requires Node.js, so let's start there.
Step 1: Install Node.js
Check Node Version:
- Open your terminal and run:
node --version
- If it's not installed or below v18, download the latest LTS from nodejs.org. For macOS/Linux, use a package manager:
brew install node # macOS with Homebrew
sudo apt install nodejs # Ubuntu
Step 2: Install Git (Optional but Recommended)
Codex CLI works best with Git for version control, avoiding warnings during setup.
Check Git Version:
- Run:
git --version
- If not installed, get it from git-scm.com. For macOS/Linux:
brew install git # macOS
sudo apt install git # Ubuntu
Step 3: Install Codex CLI
Now, the main event—installing Codex CLI globally.
Run the Install Command:
npm i -g @openai/codex
- This fetches the latest version. For macOS/Linux, it might prompt for sudo if needed.
Windows-Specific Installation
Windows isn't officially supported yet, but you can use WSL (Windows Subsystem for Linux) or download binaries.
- Using WSL:
- Enable WSL in Windows Features, install Ubuntu from Microsoft Store, and follow macOS/Linux steps inside WSL.
2. Direct Binary Download:
- Go to github.com/openai/codex/releases/tag/rust-v0.29.0.
- Download the Windows binary (e.g.,
codex-windows.exe
). - Add it to your PATH or run directly from its folder.
Test the installation by running codex
—you should see the CLI prompt. If not, check your PATH and Node setup.
Setting Up Your OpenAI API Key
Codex CLI needs an OpenAI API key to access Codex models. Let's get one.
1. Create an API Key:
- Head to platform.openai.com/api-keys.
- Click "Create new secret key."
- Name it (e.g., "Codex Key") for easy tracking in usage reports.
- Set permissions to "All" (or restrict if needed).
- Copy the key—it's shown only once!

2. Set as Environment Variable:
- In your terminal:
export OPENAI_API_KEY=<your key>
- For Windows (PowerShell):
$env:OPENAI_API_KEY = '<your key>'
- To persist it, add to your shell profile (e.g.,
.bashrc
or.zshrc
on macOS/Linux, or PowerShell profile on Windows).
This key powers Codex CLI's AI features. Monitor usage at OpenAI's dashboard to track costs.
Creating a Project and Testing Codex CLI
Let's put Codex CLI to work by building a simple todo app. We'll set up a Git repo to avoid warnings.
1. Create a Project Folder:
- Run:
mkdir codex-app
cd codex-app
2. Initialize Git:
- Run:
git init
- This sets up version control, letting you rollback changes if needed. It's optional but recommended for safety.
3. Start Codex CLI:
- Run:
codex
- If you skipped Git, hit "y" to proceed despite the warning.
- The CLI loads with the default o4-mini model and "suggest" approval mode (prompts before changes).

4. Test a Simple Prompt:
- Type a prompt like:
Create a React webapp with shadcn that is a todo app with persistence.
- Codex CLI generates the app, installing packages and creating files like
App.js
.

5. Run the App:
- Follow Codex's instructions, e.g.:
npm install
npm run dev
- Open
http://localhost:3000
to see your todo app with persistence (likely using localStorage).

6. Check Usage:
- Visit platform.openai.com/usage to see credits spent—expect minimal for this prompt.

This test shows Codex CLI's power: AI-generated code in minutes!
Exploring Codex CLI Features
Codex CLI is packed with powerful tools designed to supercharge your coding workflow. Let's break down its key features and how to use them effectively.
Flexible Authentication
Get started quickly by signing in with your ChatGPT account, ideal for free-tier users, or use an API key for more control over usage and permissions, similar to legacy tools like Claude Code.

Gain Insight with Transcripts and Status
Unlike some tools, Codex CLI operates as a "black box" by default. To see the behind-the-scenes reasoning, tools used, and raw outputs, press Esc
twice or Ctrl + T
to open the Transcript window. This is invaluable for debugging and understanding its process. Press q
to return to the main interface.
For a quick overview of your environment, use the /status
command. It displays your current workspace directory, active model, and token usage, helping you track costs and configuration at a glance.

Sandbox Modes for Maximum Safety
Security is a core priority. Codex CLI runs in a secure sandbox by default, preventing accidental changes to your system files, processes, or network.
You have fine-grained control over its permissions through three sandbox modes:
read-only
: Safely explore and analyze code without making any changes.workspace-write
: Allow file edits only within the current project directory.danger-full-access
: Grants full system access. Use with extreme caution.
Pair the --sandbox
flag with --ask-for-approval
(with options: on-request
, never
, on-failure
, untrusted
) for granular control over when it can execute code. For a completely hands-off, high-risk mode, you can use:
codex --sandbox danger-full-access --ask-for-approval never
- The shorthand command:
codex --yolo
Always verify your current mode using /status
to ensure you're working at the appropriate safety level.
Advanced Model Configuration and Switching
Use /models
to list available OpenAI models and switch between them (e.g., to GPT-4o
). The tool's versatility extends beyond OpenAI; you can configure it to run any model with an OpenAI-compatible API, such as local models via Ollama.
Further customize model behavior in the .codexrc.json
configuration file:
reasoning_effort
(minimal
/low
/medium
/high
): Controls the depth of the model's reasoning.summary
(auto
/concise
/detailed
): Adjusts the detail level of its summaries.verbosity
(low
/medium
/high
): Manages the verbosity of its responses.

Rich Input Options
Provide rich context to the AI effortlessly. Use the @
symbol to attach files (e.g., @script.py
) for analysis. Press Ctrl + V
to paste images directly from your clipboard, a powerful feature for visual tasks and debugging.
Codex CLI vs. Claude Code
While both Codex CLI and Claude Code are powerful AI coding assistants, they cater to slightly different needs and preferences. Here’s how they currently compare:
Feature Comparison
Claude Code (Anthropic) excels with a rich set of features aimed at productivity and customization:
- Custom status lines, prompts, and output styles
- Support for visual context like images and diagrams
- Session resuming and background tasks
- Specialized hooks for extensibility and sub-agents
- Vim mode and built-in security reviews
- Well-structured, beginner-friendly documentation
Codex CLI (OpenAI), though newer, focuses on flexibility and safety:
- Tight integration with OpenAI models (e.g., GPT-4o)
- Sandbox modes and approval flags for safe code execution
- Transcript view for transparency in reasoning and tools
- Support for non-OpenAI models via OpenAI-compatible APIs
- Configurable model behavior (reasoning effort, summary, verbosity)
- File attachments and image input support
At the moment, Claude Code feels more polished and feature-rich—especially for advanced users—but Codex CLI provides a solid foundation with unique strengths in safety and model interoperability.
Pricing Comparison
- Codex CLI: Free to use, but you pay for OpenAI API usage (e.g., GPT-4o costs $2.50 per 1M input tokens). No monthly subscription—you only pay for what you use, though heavy usage can become expensive.
- Claude Code: Free tier available (Claude 3.5 Sonnet, limited to 14 messages per 3 hours). Claude Pro ($20/month) offers higher limits and access to Claude Opus. No per-token fees, but usage is rate-limited.
For light usage, Claude Code’s free tier is generous and beginner-friendly. Codex CLI can be more cost-effective for intermittent use, but those with high volume may prefer Claude’s predictable pricing.
The Bottom Line
Claude Code currently holds an edge in features and documentation, making it ideal for developers wanting a refined experience today. However, Codex CLI—backed by OpenAI—is rapidly evolving. Its open design, model-agnostic support, and safety features position it as a tool with significant potential. For those willing to explore an up-and-coming platform, Codex CLI is already a compelling choice—and one likely to become even more competitive over time.
Conclusion
You've now mastered Codex CLI—from installation to building a todo app and exploring advanced features. Compared to Claude Code, Codex CLI holds its own with OpenAI integration and sandbox safety, though Claude leads in polish and pricing for free users. Whether you're prototyping or automating, Codex CLI is a versatile tool. Try the todo app prompt, experiment with yolo mode, and let me know your thoughts in the comments—happy coding!
