Sandbox SDK
Providers

Daytona

Run Daytona workspaces through the normalized SDK API.

Daytona provides persistent workspaces with files, processes, authenticated previews, custom images, and native compute controls.

Installation

Terminal
bun add @opencoredev/sandbox-sdk @daytona/sdk

Authentication

Set DAYTONA_API_KEY, or pass apiKey to daytona(). DAYTONA_API_URL and DAYTONA_TARGET select a custom endpoint or target.

Run a command

daytona.ts
import { withSandbox } from "@opencoredev/sandbox-sdk";
import { daytona } from "@opencoredev/sandbox-sdk/daytona";

await withSandbox({ provider: daytona() }, async (sandbox) => {
  const result = await sandbox.run("node --version");
  console.log(result.stdout);
});

Run an agent

Export one provider instance and pass it to AI SDK, HarnessAgent, Eve, or Mastra.

agent-provider.ts
import { daytona } from "@opencoredev/sandbox-sdk/daytona";

export const agentSandboxProvider = daytona();

Files and processes

workspace.ts
await sandbox.files.write("index.mjs", `console.log("ready")`);
const process = await sandbox.processes.start("node index.mjs");

for await (const event of process.output()) {
  console.log(event.stream, event.data);
}

Daytona supports persistent files, background processes, stdin, cancellation, and separate background output streams.

Ports and snapshots

Private previews keep the Daytona token inside preview.request(). Daytona snapshot and fork operations create provider resources, so they remain on sandbox.raw instead of the normalized in-place snapshot API.

preview.ts
const preview = await sandbox.ports.expose(3000);
const response = preview.request ? await preview.request("/") : await fetch(preview.url);

Options

OptionTypeDefaultBehavior
apiKeystringDAYTONA_API_KEYAuthenticates Daytona requests.
apiUrlstringDAYTONA_API_URLSelects the API endpoint.
targetstringDAYTONA_TARGETSelects the execution target.
imagestringProvider defaultCreates the workspace from an image.
languagestringProvider defaultSelects the workspace language.
namestringGeneratedSets the sandbox name.
publicbooleanProvider defaultControls whether preview URLs are public.

Behavior

  • Foreground command output is combined; background events retain separate stdout and stderr streams.
  • The filesystem persists with the Daytona workspace.
  • Custom images, PTY, network controls, and GPU configuration remain available through sandbox.raw.
  • Some binary and streaming methods require a Node.js-compatible runtime.

See Processes, compare exact modes in Compatibility, or connect Daytona to HarnessAgent.

On this page