# Run Codex in the cloud

> Keep Codex working with your laptop closed: the ways to run it in the cloud, and how to run the Codex CLI on a box that stays on, check on it from your phone, and what it costs.

URL: https://prized.dev/docs/run-codex-in-the-cloud

A sleeping laptop runs nothing, so closing the lid stops the Codex CLI mid-task, and the ChatGPT app's remote access stops whenever the computer it connects to sleeps ([OpenAI's docs](https://learn.chatgpt.com/docs/remote-connections)). To keep Codex working, run it on a machine that stays on:

* **Codex Cloud.** Tasks run on machines OpenAI manages, from an environment Codex prepares out of your GitHub repositories; each task gets its own workspace and keeps working while your computer sleeps ([OpenAI's docs](https://learn.chatgpt.com/docs/cloud)).
* **The Codex CLI in tmux on a server you run.** You maintain the machine and move your code there with git.
* **A Prized box.** A Linux machine that stays on, with the Codex CLI preinstalled, your project folder synced both ways, and its ports on your localhost; what Codex installs and builds stays on its disk. The steps follow.

## 1. Put your project on a box [#1-put-your-project-on-a-box]

Sign up at [prized.dev](https://prized.dev/sign-in): the tour starts a box on $30 of free credit with no card, then shows one command that installs the CLI and signs this machine in ([Quickstart](https://prized.dev/docs/quickstart)). Then run setup in your project folder:

```bash
cd ~/code/myproject
prized setup --agent codex --attach
```

It syncs this folder with `~/code/myproject` on the box, signs Codex in on the box, starts Codex there in a tmux session named `codex`, and opens that session in this terminal. With a ChatGPT sign-in, setup opens a sign-in page in your browser so the box gets a sign-in of its own and the one on your laptop stays signed in ([Credentials](https://prized.dev/docs/credentials)). Already have a box? Skip the sign-up and run just the setup.

## 2. Close the lid [#2-close-the-lid]

Give Codex its task, then close the terminal or the laptop. The session belongs to the box, so Codex keeps working, and its edits sync to your laptop when it wakes ([Sync](https://prized.dev/docs/sync#offline)). If the session is gone, this starts it again:

```bash
prized agents run codex --attach --dir code/myproject
```

If the session holds only a shell, as it does when the dashboard's **Codex** row opened it while Codex wasn't running, that command reports the session as already running and starts nothing: run `prized ssh --kill codex` first.

## 3. Check on it from anywhere [#3-check-on-it-from-anywhere]

* **From a computer:** `prized ssh -s codex`. On another computer, install the CLI and run `prized login` first.
* **From your phone or any browser:** open the box on the [dashboard](https://prized.dev/dashboard). The arrow beside **Open terminal** lists **Codex**, which opens the box's terminal in the `codex` session.
* **New chats from the ChatGPT app on your phone:** add the box as an SSH host with a phone password from the box's settings, and start Codex chats on the box with no computer awake; they are separate from the `codex` session ([Codex remote](https://prized.dev/docs/codex#from-your-phone)).

## Or hand it a task and walk away [#or-hand-it-a-task-and-walk-away]

```bash
prized prompt --provider codex --cwd code/myproject --auto --detach "run the test suite and fix what fails"
```

This runs Codex headless on the box and returns at once; `prized events --follow` follows the run. `--auto` lets it run commands without asking ([Prompt an agent remotely](https://prized.dev/docs/remote-agents#approvals)).

With an updated box agent that supports running-job protection (the `runs` capability), the run counts as use even while it waits on the model. A turn that prints nothing for 6 hours stops counting. On an older agent, or when support is unknown, the run counts for one idle window after it starts, then only while it keeps the CPU or network busy. In that case, or if the task can stay silent longer, run `prized box auto-pause BOX off` before starting it ([Auto-pause](https://prized.dev/docs/boxes#auto-pause)).

## What it costs [#what-it-costs]

|  | Small (4 vCPU, 16 GB) | Nano (2 vCPU, 2 GB) |
| --- | --- | --- |
| Awake, per hour | $0.137 | $0.014 |
| A 10 hour run overnight | $1.37 | $0.14 |
| How long $30 of free credit lasts, awake around the clock | About nine days | About three months |

Asleep, a box pays only for its disk ([Billing](https://prized.dev/docs/billing)). On the free credit, a box sleeps after 2 hours idle, never in its first 24 hours; Codex's output in its tmux session counts as use, so the box stays up while it prints ([Auto-pause](https://prized.dev/docs/boxes#auto-pause)). Nano through Small keep Codex's session through a pause, and `prized box pause` sleeps it at once ([Pause and resume](https://prized.dev/docs/boxes#pause-and-resume)).

Running Claude Code too? [Keep Claude Code running with your laptop closed](https://prized.dev/docs/keep-claude-code-running) has the same steps for it, and [Run multiple Claude Code and Codex agents in parallel](https://prized.dev/docs/parallel-agents) puts several on one box.
