Fly Machines

A sandbox per Fly Machine over the Machines REST API. Pure fetch — no SDK — so it runs anywhere the core does, including the edge.

Installation

No provider SDK required — the adapter talks to the Fly Machines REST API with fetch, so it's edge-portable.

pnpm add sbox-sdk

Usage

import { createSandboxClient } from "sbox-sdk";
import { fly } from "sbox-sdk/fly";

const client = createSandboxClient({
  provider: fly({
    apiToken: process.env.FLY_API_TOKEN!,
    appName: "my-fly-app", // must already exist
    region: "iad",
  }),
});

const sandbox = await client.create({ template: "ubuntu:22.04" });
const res = await sandbox.commands.run("uname -a");
console.log(res.stdout);

The Fly app must exist; each sandbox is a Machine inside it. template is the machine's container image.

Fly's /exec is buffered and has no per-command cwd/env, so the core folds those into a cd … && KEY=v … wrapper (perCommandEnvCwd: false) and streaming is emulated. stop() releases compute but the rootfs resets unless a volume is attached (preservesDiskOnStop: false). Files are read and written via exec + base64.

Authentication

An API token + the target app name.

Authentication variables for the fly adapter.
OptionEnv varRequiredDescription
apiTokenFLY_API_TOKENrequiredFly API token (`fly auth token`).
appNameFLY_APP_NAMErequiredThe Fly app the machines run in (must already exist).
regionFLY_REGIONoptionalDefault region, e.g. "iad".
imageoptionalDefault machine image.
appDomainoptionalPublic app domain for preview URLs; defaults to <appName>.fly.dev.
apiBaseUrloptionalOverride the Machines API base URL.

Options

Prop

Type

Capabilities

CapabilityLevelNotes
list / regionnative
stop / pausenativepause = suspend (memory kept)
streamingemulated/exec is buffered
filesUploadnativevia exec + base64
exposePortnativepreview at <app>.fly.dev
codeInterpreterunsupported
snapshot / forkunsupported

perCommandEnvCwd is false (core wraps); preservesMemoryOnPause is true; preservesDiskOnStop is false; previewModel is subdomain.

On this page