How to Install and Use Codex CLI: OpenAI's Response to Claude Code

Discover Codex CLI, OpenAI's AI coding tool. Learn setup, features like yolo mode, and how it compares to Claude Code on pricing and capabilities.

Ashley Goolam

Ashley Goolam

8 September 2025

How to Install and Use Codex CLI: OpenAI's Response to Claude Code

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 a great API Testing tool that generates beautiful API Documentation?

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!
button

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.

codex cli

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!

claude code

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:

node --version
brew install node  # macOS with Homebrew
sudo apt install nodejs  # Ubuntu

Codex CLI works best with Git for version control, avoiding warnings during setup.

Check Git Version:

git --version
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

Windows-Specific Installation

Windows isn't officially supported yet, but you can use WSL (Windows Subsystem for Linux) or download binaries.

  1. Using WSL:

2. Direct Binary Download:

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:

create a secret key

2. Set as Environment Variable:

export OPENAI_API_KEY=<your key>
$env:OPENAI_API_KEY = '<your key>'

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:

mkdir codex-app
cd codex-app

2. Initialize Git:

git init

3. Start Codex CLI:

codex
codex warning

4. Test a Simple Prompt:

Create a React webapp with shadcn that is a todo app with persistence.
todo app created

5. Run the App:

npm install
npm run dev
a simple todo app

6. Check Usage:

open ai usage limits

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.

sign in with an api key or chat gpt

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.

transcript window

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:

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:

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:

witch between models

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:

Codex CLI (OpenAI), though newer, focuses on flexibility and safety:

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

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!

button
apidog

Explore more

PayPal Users Score Big: How to Get 12 Months Free Perplexity Pro + Comet Browser

PayPal Users Score Big: How to Get 12 Months Free Perplexity Pro + Comet Browser

PayPal just dropped a game‑changer: free 12‑month Perplexity Pro subscriptions ($200 value) plus early Comet browser access for US users. Here's how to claim yours.

5 September 2025

What is Twilio API?

What is Twilio API?

Discover what Twilio API is, how it works, and why it powers SMS, voice, chat, and video features in modern apps and how Apidog helps your APIs.

5 September 2025

Top 7 Free Movie APIs

Top 7 Free Movie APIs

A clear, developer‑friendly guide to Free Movie APIs: what they offer, how they differ, and where they fit. Plus, how Apidog helps you design, test, and ship movie data integrations faster and safer.

5 September 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs