# Run the pi coding agent in the cloud

> Keep pi working with your laptop closed: run it on a box that stays on, sign it in there once, check on it from your phone, and what it costs.

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

A sleeping laptop runs nothing, so closing the lid stops [pi](https://pi.dev) mid-task. To keep it working, run it on a machine that stays on:

* **pi in tmux on a server you run.** You install it, maintain the machine, and move your code there with git.
* **A Prized box.** A Linux machine that stays on, with your project folder synced both ways and its ports on your localhost; one command installs pi there and starts it. 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 --no-start
```

It syncs this folder with `~/code/myproject` on the box; `--no-start` keeps setup from starting Claude Code or another agent there. Already have a box? Skip the sign-up and run just the setup.

## 2. Start pi on the box [#2-start-pi-on-the-box]

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

The first run installs pi on the box from a pinned release, checked against its SHA-256, then starts it in your project in a tmux session named `pi` and opens that session in this terminal. A copy you installed on the box yourself is used instead.

pi has no models until it has a provider, and your laptop's pi sign-in does not travel, so give it one on the box:

* **A key:** add a provider key such as `ANTHROPIC_API_KEY` or `OPENROUTER_API_KEY` as a Secret ([Keys for other agents](https://prized.dev/docs/credentials#keys-for-other-agents-and-backends)), then quit pi and run the same command to restart it with the key.
* **Or `/login` in pi:** pick an account or an API key, then a provider, and follow its prompt; a sign-in that finishes in a browser ends with pasting back a code or the address the browser lands on.

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

Give pi its task, then close the terminal or the laptop. The session belongs to the box, so pi keeps working, and its edits sync to your laptop when it wakes ([Sync](https://prized.dev/docs/sync#offline)). The same `prized agents run pi --attach --dir code/myproject` opens the session again, or starts pi again if the session is gone. If the session holds only a shell, as it does when the dashboard's **pi** row opened it while pi wasn't running, that command reports the session as already running and neither installs nor starts pi: run `prized ssh --kill pi` first.

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

* **From a computer:** `prized ssh -s pi`. 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 **pi**, which opens the box's terminal in the `pi` session.

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

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

This runs pi headless on the box and returns at once; `prized events --follow` follows the run. pi has no approvals, so without `--auto` it gets no `bash` tool and edits files without running commands; `--auto` adds it ([Prompt an agent remotely](https://prized.dev/docs/remote-agents#approvals)). `--model openrouter/…` and the like pick a backend ([Models and backends](https://prized.dev/docs/remote-agents#models-and-backends)).

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; pi'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 pi's session through a pause, and `prized box pause` sleeps it at once ([Pause and resume](https://prized.dev/docs/boxes#pause-and-resume)).
