# Run OpenCode in the cloud

> Keep OpenCode working with your laptop closed: run it on a box that stays on, check on it from your phone, and what it costs.

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

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

* **OpenCode 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 OpenCode 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 OpenCode on the box [#2-start-opencode-on-the-box]

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

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

OpenCode starts on its free models, which need no key; they are free for a limited time, and some may use what you send to improve the model ([OpenCode Zen](https://opencode.ai/docs/zen)). For private code, connect your own provider on the box, since your laptop's OpenCode sign-in does not travel:

* **Sign in:** type `/connect` in OpenCode, or run `opencode auth login` in a shell on the box.
* **Or use a key:** add the provider's key as a Secret ([Keys for other agents](https://prized.dev/docs/credentials#keys-for-other-agents-and-backends)), then quit OpenCode and run the same command to restart it with the key.

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

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

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

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

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

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

This runs OpenCode headless on the box and returns at once; `prized events --follow` follows the run. `--auto` lets it run commands; without it, OpenCode edits files but its shell commands are refused ([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; OpenCode'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 OpenCode's session through a pause, and `prized box pause` sleeps it at once ([Pause and resume](https://prized.dev/docs/boxes#pause-and-resume)).

Rather work in opencode Desktop? [Use opencode Desktop with a Prized box](https://prized.dev/docs/opencode-desktop) runs its sessions on the box. Models and backends for headless runs are on [Prompt an agent remotely](https://prized.dev/docs/remote-agents#models-and-backends).
