Codex Cloud Setup: Environments, Cloud Tasks, and the codex cloud CLI
Codex Cloud (called Codex Web in the source) is the hosted Codex surface: tasks run in cloud environments organized per GitHub repo, and the codex cloud CLI submits, tracks, and pulls diffs back to your machine.
How to
Prepare an environment in Codex Web
Open chatgpt.com/codex, connect GitHub as prompted, and create a cloud environment for the target repo (exact UI fields are as shown in the product). Environments are per-repo, so confirm the repo is connected first.
Verify environment detection locally
Run codex cloud inside your local clone to open the task-browsing TUI; the CLI reads the GitHub origin remote and matches the cloud environment automatically. Ctrl+O switches environments.
Submit a cloud task
Run codex cloud exec with a task description and --env ENV_ID; add --attempts 2 (max 4) for multiple tries and --branch to pick a branch.
Track progress and inspect the result
Use codex cloud status or list to follow the task; when it finishes, codex cloud diff shows the produced patch.
Apply the result locally
After review, run codex cloud apply with the task ID to land the diff in your working tree, then test and commit as usual.
Codex Cloud is OpenAI Codex's hosted execution surface — the openai/codex README states it plainly: if you want the cloud-based agent (called Codex Web in the repo), head to chatgpt.com/codex. Unlike the local CLI, cloud tasks run in a managed environment on a cloud copy of your code, and the result comes back as a diff you pull down locally. This guide is grounded in the openai/codex source at tag rust-v0.156.1 (released 2026-09-23).
1. Where Cloud sits among the three surfaces
Codex ships three working surfaces: the local CLI, the IDE extension, and Codex Cloud. They share the same model and engineering capabilities; what differs is where execution happens — Cloud moves it into a hosted environment, which suits long-running, batch, and unattended work. Surface selection has its own article; this one focuses on Cloud setup and the command surface (see Codex CLI vs IDE Extension vs Codex Cloud: Choosing a Codex Surface).
2. Prerequisites
- A ChatGPT account with Codex access (availability and tier limits are as shown in your account)
- Target code hosted on GitHub — cloud environments are organized per GitHub repo, and CLI-side detection only reads GitHub remotes (see section 3)
- Codex CLI installed and signed in locally (see Getting started with OpenAI Codex CLI: from install to daily use)
3. Environments: organized per GitHub repo
The core Codex Cloud concept is the environment: each one binds to a GitHub repository, and tasks run on a cloud copy of that repo. In the source, environment objects carry id, label, is_pinned, and task_count fields, and a repo can have several environments.
Detection is automatic on the CLI side: codex cloud reads your local git remotes, resolves the GitHub origin into owner/repo, and matches it against the environments configured in the cloud (the source notes this matches the VSCode extension's behavior). Your clone's remote URL decides which environment a task runs in — a fork and its upstream are different environments.
Environment creation happens on the web side at chatgpt.com/codex (exact UI fields as shown in the product). What this article can verify is the mechanism: environments follow the repository, not the directory.
4. The codex cloud command surface (EXPERIMENTAL)
The CLI entry point is codex cloud (alias codex cloud-tasks), marked EXPERIMENTAL in the source — "Browse tasks from Codex Cloud and apply changes locally." Run it bare for the task-browsing TUI (Ctrl+O opens the environment picker):
codex cloud # task-browsing TUI, Ctrl+O switches environments
codex cloud-tasks # equivalent alias
Scripted use goes through five subcommands:
| Subcommand | What it does |
|---|---|
codex cloud exec | Submit a new cloud task without launching the TUI |
codex cloud status | Show a cloud task's status |
codex cloud list | List cloud tasks (--env filter, --limit 1-20, --cursor pagination, --json output) |
codex cloud apply | Apply a task's diff to your local tree (--attempt picks which try) |
codex cloud diff | Show a task's unified diff (also takes --attempt) |
exec has three flags worth knowing (defined in cli.rs):
codex cloud exec "add form validation to the login page" --env env_xxx --attempts 2 --branch main
--env ENV_ID: required. The target environment ID — browseable in the TUI (the flag help literally says: seecodex cloudto browse)--attempts N: best-of-N, accepting 1 through 4, default 1 — run the task several times and pick among results--branch BRANCH: which branch runs in the cloud; defaults to your current branch
Tracking and collecting a submitted task:
codex cloud list --env env_xxx --json # list tasks (--limit 1-20, --cursor pagination)
codex cloud status <task-id> # single-task status
codex cloud diff <task-id> # view the patch; with best-of-N use --attempt 2
codex cloud apply <task-id> --attempt 1 # land the chosen attempt's diff locally
5. Suggested workflow
- Create an environment for the target repo on the web side (as shown in the product)
- Run
codex cloudlocally and confirm the environment is autodetected - Start with a single
execrun (default--attempts 1); use best-of-N when the solution space is wide - When it finishes, review with
codex cloud diff, thencodex cloud applyto land it — cloud output gets the same human review as local output - If a task misbehaves, check the Codex Web component on status.openai.com first (it is a standalone entry in the official component list), then verify your git remote and environment ID
6. Common errors and troubleshooting
- No environment detected: check that the git remote is a GitHub URL (detection only reads GitHub origins) and that a cloud environment exists for the repo
execargument errors:--attemptsonly accepts 1-4;--envis required and must be a real environment ID- Task stuck: check the Codex Web status component first, then confirm the branch exists in the cloud repo
- apply conflicts: the cloud result is a patch; if local edits touched the same regions while the task ran, resolving overlaps is manual after apply
7. Next steps
- Codex CLI vs IDE Extension vs Codex Cloud: Choosing a Codex Surface — when a task belongs in the cloud
- Codex CLI config.toml: The Complete Guide to Models, Approvals, MCP and Layered Config — the local side of configuration
- Getting started with OpenAI Codex CLI: from install to daily use — install and sign-in
Key points
- The official entry point is chatgpt.com/codex; the openai/codex README points cloud-agent seekers there (named Codex Web in the repo)
- Cloud environments are organized per GitHub repo: the CLI autodetects the environment from your local git remote (GitHub origins only)
- codex cloud is an experimental subcommand (alias cloud-tasks): exec submits a task, status/list query, apply lands the diff locally, diff shows the patch
- exec takes --attempts 1-4 for best-of-N tries and --branch (defaults to your current branch); --env is required
- Codex Web has its own component entry on status.openai.com for outage checks
Frequently asked questions
Official references
Related articles
Codex CLI config.toml: The Complete Guide to Models, Approvals, MCP and Layered Config
Codex CLI centers on ~/.codex/config.toml: model picks the model, approval_policy gates prompts, sandbox_mode sets boundaries, mcp_servers wires tools, profiles switch scenarios.
Read articleCodex CLI Sandbox Modes: sandbox_mode and approval_policy Explained
Codex CLI sandbox has four levels — read-only, workspace-write, external-sandbox, danger-full-access — plus a separate approval_policy axis. Every value checked against the codex source enums.
Read articleCodex CLI 0.155, Explained: Experimental /voice, Touch ID for MCP Requests, and the 0.155.1 Revert
Codex CLI 0.155.0/0.155.1 back to back: experimental /voice behind /experimental, streaming reasoning summaries, Touch ID for MCP requests, daemon update schedules, Bedrock credentials — plus the 0.155.1 reasoning-summary revert.
Read articleSubscribe to GPTMap Weekly
One email every Monday: curated OpenAI updates, deep dives, and best practices. No ads, unsubscribe anytime.
Submitting opens Buttondown in a new tab to confirm your subscription.