Free Track

OpenAI for Coding — Overview

If you already use Claude Code, OpenAI's coding tools will feel familiar: the same idea of an AI that reads your repo, edits files, and runs commands. This free overview maps the three OpenAI surfaces you'll actually reach for — the Codex CLI, ChatGPT / Codex cloud, and the API — shows the Codex CLI in action, and lines it up next to Claude Code so you can move between them without relearning the mental model.

What "Codex" means today. OpenAI uses the name Codex for its current agentic coding product, not the retired 2021 code model. In practice "Codex" shows up as a terminal tool (the Codex CLI), inside ChatGPT and a cloud environment, and as models you call through the API. This page is about the terminal-first workflow, which is the closest analog to Claude Code.

The three OpenAI coding surfaces

There isn't one "OpenAI coding tool" — there are three surfaces that share models but suit different jobs. Picking the right one is most of the battle.

SurfaceWhat it isReach for it when…
Codex CLI An agentic tool that lives in your terminal, reads and edits files in the repo you're standing in, and runs commands with your approval. You want hands-on, local, iterative coding on a real checkout — the everyday driver.
ChatGPT / Codex cloud Codex running in a hosted cloud environment (reachable from ChatGPT and from codex cloud), where tasks execute remotely and in parallel. You want to delegate a task and walk away, run several jobs at once, or kick off work from a browser instead of your laptop.
The API Direct programmatic access to OpenAI models from your own code. You're building your own product/feature on top of a model, not editing a repo interactively.

Rule of thumb: local, interactive, "sit with it" work → Codex CLI. Fire-and-forget or parallel work → Codex cloud. Embedding a model inside software you ship → API. Most people live in the CLI and occasionally push a long task to the cloud.

Codex CLI at a glance

The Codex CLI is a single binary you install once, sign into, and then run inside any project directory. Four things get you productive: install it, launch it, sign in, and learn the one command that makes it scriptable.

1 · Install

Pick whichever matches your setup — they install the same tool.

Install script (macOS / Linux) The one-line installer from OpenAI.
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Install script (Windows PowerShell) The PowerShell equivalent.
irm https://chatgpt.com/codex/install.ps1 | iex
npm (any OS with Node) Global install via npm — handy if you already manage tools with Node.
npm install -g @openai/codex
Homebrew (macOS) If you live in Homebrew.
brew install --cask codex

2 · Launch it in your project

cd into a repository and run codex. Just like Claude Code, it starts an interactive session scoped to that directory — it reads the files there and proposes edits and commands you approve.

codex Start an interactive agent session in the current repo.
cd my-project
codex

3 · Sign in

On first run Codex asks you to authenticate. The simplest path is "Sign in with ChatGPT" using a paid ChatGPT plan (Plus / Pro / Business / Edu / Enterprise) — no API key to manage. Alternatively you can authenticate with an API key if you'd rather pay per use or run in an environment without a browser login.

Which auth? Sign in with ChatGPT if you already pay for ChatGPT and want usage bundled into that plan. Use an API key for CI, servers, or metered billing where a browser sign-in isn't practical.

4 · Learn codex exec

The interactive codex session is where you'll spend most of your time, but the command that unlocks automation is codex exec: a non-interactive (headless) mode that runs a single instruction and exits, printing its result. It's the piece you drop into scripts and CI.

codex exec "…" Run one task non-interactively and exit — the scripting/CI entry point.
codex exec "run the test suite and fix any failing unit tests"

A tour of different usage

Beyond "launch and chat," a handful of subcommands and flags cover most real workflows. Each of these is copy-pasteable — try them in a scratch repo.

Resume where you left off Reopen a recent session from this repo instead of starting cold.
codex resume
Delegate to the cloud Push a task to a hosted environment so it runs remotely / in parallel.
codex cloud
Pick a model + reasoning effort Trade speed for depth on a per-run basis.
codex -m <model-name> "refactor the auth module and explain the trade-offs"
Give it a screenshot Attach visual context — an error screenshot, a design, a diagram.
codex --image ./bug.png "the layout breaks like this on mobile — find and fix the cause"
Let it search the web Enable live web search for up-to-date context (library changes, error messages).
codex --search "upgrade us to the latest stable version of this framework"
Full automation (careful) Run without stopping to approve each step — great for trusted tasks, risky for anything destructive.
codex --full-auto "add a README section documenting the config options"

For unattended runs, codex exec is the star. Here it is inside a CI job that runs on every push and lets the agent fix failing tests headlessly:

# .github/workflows/codex.yml (illustrative)
name: codex-autofix
on: [push]
jobs:
  autofix:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm install -g @openai/codex
      - run: codex exec "run the test suite; if tests fail, fix them and summarize what changed"
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Slash commands and project instructions

Inside an interactive session, slash commands manage the session itself — familiar territory if you know Claude Code's / menu:

CommandWhat it does
/initGenerates an AGENTS.md — the project instructions file Codex reads (the Claude CLAUDE.md analog).
/statusShows the current session's state.
/permissionsReviews and adjusts what the agent is allowed to do.
/modelSwitches the model and reasoning effort mid-session.
/reviewAsks Codex to review the current changes.

Just like CLAUDE.md, AGENTS.md is a plain Markdown file at the root of your repo where you write standing instructions — conventions, how to run tests, what to avoid — so you don't repeat them every session. Codex reads it automatically.

How Codex CLI maps to Claude Code

Both are agentic terminal tools: you run them inside a repo, they read and edit files, run commands with your approval, and take standing instructions from a Markdown file. If you know one, this table gets you productive in the other quickly.

ConceptClaude CodeCodex CLI
Launch interactiveclaudecodex
Headless / one-shotclaude -p "…"codex exec "…"
Resume a sessionclaude --resume / /rewindcodex resume
Project instructions fileCLAUDE.mdAGENTS.md
Create that file/init/init
Switch model mid-session/model/model or -m
Manage permissions/permissions/permissions
Autonomy dialpermission modes (defaultbypassPermissions)approval modes (suggest → auto → --full-auto)
Connect MCP serversclaude mcpcodex mcp
Hosted / background workbackground agents, /schedulecodex cloud
Config filesettings.json~/.codex/config.toml

The one difference to internalize: the vocabulary. Codex talks about approval modessuggest (asks first), auto, and full-auto (complete automation) — plus a read-only sandbox and writable roots. Claude Code talks about permission modes. Different words, same underlying question: how much do you let the agent do before it stops to ask?

When to use which surface

Reach for the Codex CLI when…

  • You're editing a real local checkout and want to iterate tightly
  • You want to see and approve each change as it happens
  • You're scripting a repeatable task with codex exec in CI

Reach for Codex cloud when…

  • The task is long and you'd rather not babysit it
  • You want several tasks running in parallel
  • You're kicking work off from a browser, away from your dev machine

Reach for the API when…

  • You're building a feature/product on top of a model
  • You need models embedded in your own application logic
  • You want full programmatic control, not a repo-editing agent

Pitfalls to avoid.

  • Full-auto on untrusted or destructive work. --full-auto and the higher approval modes let Codex act without stopping to ask. Great for a well-scoped, reversible task; dangerous for anything that deletes data, touches production, or runs on code you don't trust. Start in suggest mode and only loosen it once you trust the task.
  • Assuming the sandbox covers everything. The read-only sandbox and writable roots limit where Codex can write — but if you widen those roots or grant network access, you've widened the blast radius. Know what you've opened up.
  • Confusing the surfaces. Don't reach for the API to edit a repo, or expect the local CLI to run a job while your laptop is asleep — that's what codex cloud is for. Matching the surface to the task saves the most time.
  • Treating model names and plans as permanent. Model IDs, plan tiers, and included usage change often. Confirm the current details in the official docs (developers.openai.com/codex) before you depend on them.

Go deeper

Ready for the full workflow? This overview is the taster. The premium "OpenAI Codex CLI in Depth" module walks through auth in detail, interactive vs codex exec vs codex resume, every slash command, approval & sandbox modes and their flags, AGENTS.md patterns, ~/.codex/config.toml, codex mcp, and codex cloud — with a full Codex-vs-Claude-Code mapping and worked CI recipes.

Open “OpenAI Codex CLI in Depth” →