Codex CLI: how it works and differs from App and Web
Learn how Codex CLI works in a local terminal, accesses repositories, runs commands, applies project rules, and differs from Codex App and Codex Web workflows.
Codex CLI is OpenAI’s local command-line coding agent. It runs in your terminal, works with the selected workspace, reads and edits files, runs commands, and applies your sandbox and approval settings. Unlike Codex App, its primary interface is the terminal. Unlike Codex Web, it runs in your local environment rather than a browser or remote runtime.
Short answer
It is useful when you want an agent to help with code changes, code review, test fixes, scripts, and multi-step engineering work inside a local repository.
Codex CLI is different from a normal ChatGPT conversation. It does not only suggest code. It works with the current directory, project instructions, tool results, and local execution permissions.
CLI, App, and Web at a glance
| Option | Where it runs | Choose it when |
|---|---|---|
| Codex CLI | Local terminal and workspace | You need commands, files, and config.toml setup |
| Codex App | Desktop application | You need graphical sessions, plugins, or Remote Control |
| Codex Web | Browser or remote environment | The task should run in a cloud or remote environment |
See Codex CLI vs Codex App vs Codex Web for a detailed comparison.
When this matters
- You are installing
@openai/codexfor the first time - You are comparing Codex CLI, Codex App, and Codex Web
- You want an agent to edit files in a local project
- You need to configure a custom API provider, Base URL, or model
- You want to understand sandbox, approval, and
AGENTS.md
Core concepts
| Concept | Meaning |
|---|---|
| Codex CLI | The Codex coding agent running in your local terminal |
| Workspace | The directory Codex can read, search, and modify |
config.toml | The local Codex config file for models, providers, sandbox, approvals, and other behavior |
AGENTS.md | A project instruction file that tells Codex repository rules and collaboration preferences |
| Sandbox | The local security boundary for filesystem, network, and command access |
| Approval | The policy that decides which actions need confirmation |
Recommended workflow
- Start Codex CLI inside the project directory you want to change.
- Ask it to inspect relevant files or instructions before making broad edits.
- For complex work, ask for a plan before letting it change files.
- Pick sandbox and approval settings based on the risk of the task.
- Put durable project rules in
AGENTS.mdand one-time requirements in the current conversation.
If you use a third-party API provider, focus on model_provider, base_url, wire_api, and model fields in config.toml. Codex and other OpenAI-compatible tools usually use an OpenAI-compatible endpoint, which is https://bettertoken.ai/v1 in this documentation.
Common mistakes
- Treating Codex CLI as a chat-only assistant.
- Assuming Codex CLI, Codex App, and Codex Web run in the same environment.
- Changing only
modelwithout configuring the matching provider and Base URL. - Relaxing sandbox and approval settings without tests, review, or command boundaries.
- Mixing OpenAI-compatible and Anthropic-compatible Base URLs.
About BetterToken
When you use a custom OpenAI-compatible provider, BetterToken can act as the model API layer for Codex CLI. It handles the API Key, Base URL, model routing, balance, and usage records.
BetterToken does not replace Codex CLI’s local sandbox, approvals, AGENTS.md, or command execution policy.
For general Codex API access and product use cases, see the BetterToken Codex API page. This FAQ focuses on Codex CLI and its local workflow.
Related docs
- Codex BetterToken setup guide
- Codex CLI vs Codex App vs Codex Web
- How to configure Codex CLI config.toml
- OpenAI-compatible API vs Anthropic-compatible API

