BlogGuide
Codex CLI: Install, Sign In, Sandbox Modes and Codex Cloud
By Utpal Nadiger · Updated November 27, 2026
The Codex CLI is OpenAI's coding agent for the terminal: it reads your repository, edits files and runs commands on your machine inside an OS-enforced sandbox. You install it with one command, sign in with your ChatGPT account, and use it on any plan that includes it, starting with Plus at $20 a month as of November 2026. The same CLI can also send tasks to Codex Cloud with codex cloud, so work keeps going after you close the laptop.
This guide covers installing the Codex CLI, sign-in, approval and sandbox modes, the cloud commands, and other ways to run Codex in the cloud.
What the Codex CLI is
Codex is OpenAI's coding agent. It comes as a desktop app, an IDE extension, a cloud product and a command-line tool. The Codex CLI docs describe the CLI as a way to inspect code, make changes, run commands and automate repeatable work without leaving the terminal. Its source is public on GitHub.
What you can do with it:
- Interactive work. Run
codexin a repo to explore code, plan a change, edit and test. - Scripts and CI.
codex execruns a task to completion without prompts. - Code review.
codex reviewreviews uncommitted changes, a commit or a branch without modifying your files. - Cloud tasks.
codex cloudsubmits and tracks tasks in Codex Cloud. - Tools.
codex mcpadds MCP servers, and--searchturns on live web search.
How to install the Codex CLI
Pick one method from OpenAI's install instructions:
# macOS and Linux, standalone installer
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# npm
npm install -g @openai/codex
# Homebrew
brew install --cask codexOn Windows, run this from a new PowerShell window:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"To update later, rerun the installer, run npm install -g @openai/codex again, or use brew upgrade --cask codex. Releases that support it can also update with codex update.
Signing in with ChatGPT or an API key
Open a project directory and run codex. The first time, choose Sign in with ChatGPT, which opens a browser. You can also sign in directly:
codex login
codex login status # exits 0 when credentials are presentPer the authentication docs, there are two sign-in methods for local work:
| Sign-in | Billing | Works for Codex Cloud |
|---|---|---|
| ChatGPT account | Your plan's included usage, then credits | Yes |
| API key | Separate pay-per-token API pricing | No, cloud requires ChatGPT sign-in |
API keys suit CI and shared machines. A ChatGPT login suits day-to-day use because the plan's included usage is usually cheaper than paying per token.
Codex CLI pricing and plans
As of November 2026, OpenAI's Codex pricing page lists:
| Plan | Price | Codex access |
|---|---|---|
| Free | $0 | Desktop app only, subject to rollout |
| Go | $8 a month | Desktop app only, subject to rollout |
| Plus | $20 a month | Web, CLI, IDE extension and iOS |
| Pro | $100, $200 or $500 a month | Everything in Plus with more usage |
| Business | $20 per user a month billed annually, $25 monthly | Team workspace |
| API key | Pay per token | CLI and IDE, not cloud |
Plus and Business have usage limits per five-hour window, and Pro plans currently have no five-hour limit. Cloud tasks may use more of your allowance than local messages. More detail is in the Codex pricing guide.
Approval modes and sandboxing
Codex separates two controls, as the approvals and security docs explain:
- Sandbox mode sets what Codex can do technically: where it can write and whether it can reach the network.
- Approval policy sets when Codex must stop and ask you.
Locally, the sandbox is enforced by the operating system (Seatbelt on macOS, and Linux and Windows have their own implementations). By default, network access is off and writes are limited to the workspace. Common combinations:
| Intent | Flags | Effect |
|---|---|---|
| Auto (default in a git repo) | --sandbox workspace-write --ask-for-approval on-request | Reads, edits and runs commands in the workspace. Asks before going outside it or using the network |
| Read-only | --sandbox read-only --ask-for-approval on-request | Reads and runs commands, cannot edit |
| Read-only CI | --sandbox read-only --ask-for-approval never | Never asks, cannot edit |
| Full access | --dangerously-bypass-approvals-and-sandbox (alias --yolo) | No sandbox and no approvals, not recommended |
Switch modes inside a session with /permissions. Even in workspace-write, the .git directory stays read-only. OpenAI's CLI reference advises using --add-dir to grant extra writable directories rather than --sandbox danger-full-access, and avoiding the bypass flag unless you are inside a dedicated sandbox VM.
To turn on network access in the workspace sandbox:
# ~/.codex/config.toml
[sandbox_workspace_write]
network_access = trueFor scripts and CI:
codex exec --sandbox workspace-write "run the tests and fix any failures"Codex Cloud from the CLI
Codex Cloud runs tasks in OpenAI-managed environments, so they continue while your computer sleeps. Per the cloud environments docs, each cloud task runs in its own workspace. You can use a default environment or publish a reusable one with repositories, setup scripts, secrets and network rules.
From the terminal:
# Open an interactive picker of cloud chats
codex cloud
# Submit a task to an environment without the TUI
codex cloud exec --env <ENV_ID> "add pagination to the users endpoint"
# List recent cloud chats, as JSON for scripting
codex cloud list --json
# Apply the latest diff from a cloud chat to your local repo
codex apply <TASK_ID>The --env flag and options like --attempts for best-of-N runs come from the CLI's source. Cloud requires ChatGPT sign-in, not an API key.
Repository access: cloud tasks can clone from a connected GitHub account, and the current docs also support GitLab.com repositories through a reusable environment. When the work is ready, you review it and commit or open a pull request. Codex Cloud also runs on the web, in the desktop app and in the Codex section of the ChatGPT mobile app. For Slack, OpenAI's @ChatGPT app can hand repository work to a Codex Cloud task when a workspace admin enables it.
Other ways to run Codex in the cloud
Codex Cloud is not the only option:
- Your own server. Install the CLI on a VM, run it inside tmux, and connect over SSH.
codex remote-controlalso lets managed clients connect to a Codex session on a machine you run. - CI.
codex execwith an API key runs Codex in GitHub Actions or any CI runner. - Another platform. Several agent platforms run the Codex CLI on their own machines. Compare options in cloud coding agents compared and Codex vs Claude Code.
Running Codex from Slack with OpenComputer
The hosted version of OpenComputer runs Codex as well as Claude Code. (The open source version runs Claude Code only.) You mention @Computer in a Slack thread, the web app chat or the API, and the agent works on a cloud Linux machine for your Slack workspace, with a git worktree and branch per thread. You can sign in with your own ChatGPT subscription or OpenAI API key, or use OpenComputer tokens at API prices, and when a subscription hits its limit you choose whether to fall back or wait.
Finished work comes back as a GitHub pull request saying what changed, why and how it was checked. As of November 2026, plans are per workspace on work minutes: a 3-day trial with 600 minutes, Pro at $20 a month for 2,000 minutes, and Max at $200 a month for 25,000. See OpenComputer vs Codex for a direct comparison.
FAQ
Is the Codex CLI free?
The CLI itself is free to install, but using it needs either a ChatGPT plan that includes it or an API key billed per token. As of November 2026 the CLI is listed from the Plus plan at 20 dollars a month, while Free and Go get Codex in the desktop app only.
How do I sign in to the Codex CLI with my ChatGPT account?
Run codex in a project folder and choose Sign in with ChatGPT, or run codex login. A browser window opens for the ChatGPT sign-in. Afterwards, codex login status confirms the credentials are present and exits with code zero.
What is the difference between the Codex CLI and Codex Cloud?
The CLI runs on your own machine inside a local sandbox and works on your local checkout. Codex Cloud runs each task in an OpenAI-managed environment that keeps working while your computer is off. The CLI can submit and track cloud tasks with the codex cloud command.
Is it safe to run Codex with full access?
Only inside an isolated, disposable environment. The bypass flag removes both the sandbox and approval prompts, so Codex can run any command and reach the network. OpenAI recommends the workspace-write sandbox with on-request approvals for normal local work.
Can the Codex CLI use an API key instead of a subscription?
Yes. The CLI and IDE extension accept an API key for local work, billed at API prices separately from any ChatGPT plan. Codex Cloud is the exception, because cloud tasks require signing in with a ChatGPT account.