> For the complete documentation index, see [llms.txt](https://docs.computesdk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.computesdk.com/providers/run-cloud.md).

# Run Cloud

[Run Cloud](https://run.cloud) provides fast Firecracker microVM sandboxes for AI agents, CI, and untrusted code execution.

## Installation & Setup

```bash
npm install computesdk @computesdk/run-cloud
```

Create an API key in the [Run Cloud dashboard](https://run.cloud), then export it:

```bash
export RUN_CLOUD_API_KEY=rc_live_your_key
```

`RUN_CLOUD_API_TOKEN` is supported as an alias. `RUN_CLOUD_API_URL` optionally targets a custom Run Cloud deployment.

## Usage

```typescript
import { compute } from 'computesdk';
import { runCloud } from '@computesdk/run-cloud';

compute.setConfig({
  provider: runCloud({
    apiKey: process.env.RUN_CLOUD_API_KEY,
    cpu: 2,
    memory: 4096,
    disk: 40,
  }),
});

const sandbox = await compute.sandbox.create({
  templateId: 'runcloud/agent-base',
  name: 'agent-task',
});

const result = await sandbox.runCommand('node --version');
console.log(result.stdout);

await sandbox.filesystem.writeFile('/tmp/result.txt', result.stdout);

const snapshot = await compute.snapshot.create(sandbox.sandboxId, {
  name: 'after-setup',
});

await sandbox.destroy();

const restored = await compute.sandbox.create({
  snapshotId: snapshot.id,
});
```

## Configuration Options

```typescript
interface RunCloudConfig {
  apiKey?: string;
  apiUrl?: string;
  fetch?: typeof fetch;
  image?: string;
  cpu?: number;
  memory?: number;
  disk?: number;
  idlePauseSeconds?: number;
  timeout?: number;
  region?: string;
  orgId?: string;
  commandTimeout?: number;
  tunnelTtlSeconds?: number;
}
```

`cpu` accepts fractional vCPUs, `memory` uses MiB, and `disk` uses GiB. `timeout` and `commandTimeout` use milliseconds; `idlePauseSeconds` and `tunnelTtlSeconds` use seconds.

Fresh creates accept per-create `templateId` or `image`, `cpu`, `memory`, `disk`, `idlePauseSeconds`, `timeoutSeconds`, `region`, `name`, `orgId`, and `idempotencyKey` overrides. Snapshot restores accept `cpu`, `memory`, `disk`, `timeoutSeconds`, `region`, and `name` overrides; options the restore API cannot apply are rejected instead of being silently ignored.

Sandbox-level environment variables are not yet persisted by Run Cloud. Pass command-scoped variables through `runCommand`:

```typescript
await sandbox.runCommand('echo "$MODEL"', {
  env: { MODEL: 'gpt-5' },
});
```

## Supported Operations

| Method       | Supported | Notes                                                                   |
| ------------ | --------- | ----------------------------------------------------------------------- |
| `create`     | ✅         | Fresh image boot or snapshot restore with resource overrides.           |
| `getById`    | ✅         | Returns `null` for missing sandboxes.                                   |
| `list`       | ✅         | Lists running sandboxes.                                                |
| `destroy`    | ✅         | Idempotent when already deleted.                                        |
| `runCommand` | ✅         | Supports cwd, env, timeout, streaming callbacks, and background mode.   |
| `getInfo`    | ✅         | Refreshes lifecycle and resource metadata.                              |
| `getUrl`     | ✅         | Opens an expiring capability URL without making the sandbox persistent. |
| Filesystem   | ✅         | Read, write, mkdir, list, exists, and remove.                           |
| Snapshots    | ✅         | Create, list, delete, and restore.                                      |

Use `sandbox.getInstance()` to access the official Run Cloud client and native sandbox record.

Tunnel hostnames are random bearer capabilities. Do not write them to public logs. They expire automatically and are removed when the tunnel or sandbox is deleted.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.computesdk.com/providers/run-cloud.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
