Use the E2B SDK

Move an E2B integration to Shardflux by changing three environment variables.

Move your existing integration

The fastest way to move an E2B integration to Shardflux is to keep your E2B SDK and change its connection settings. Your harness keeps its sandbox, command and file calls. Create a project API key in the console, then set:

Shell
export E2B_API_URL=https://e2b.shardflux.dev
export E2B_DOMAIN=e2b.shardflux.dev
export E2B_API_KEY="$SHARDFLUX_API_KEY"

The base template selects Shardflux's default Python, Node and browser environment. A sandbox id is also its Shardflux workspace id, so you can inspect it in the console or open it with the native SDK.

JavaScript

TypeScript
import { Sandbox } from 'e2b';

const sandbox = await Sandbox.create({ timeoutMs: 300_000 });
try {
  await sandbox.files.write('/home/user/input.txt', 'hello');
  const result = await sandbox.commands.run('cat /home/user/input.txt');
  console.log(result.stdout);
} finally {
  await sandbox.kill();
}

Python

Python
from e2b import Sandbox

sandbox = Sandbox.create(timeout=300)
try:
    sandbox.files.write('/home/user/input.txt', 'hello')
    result = sandbox.commands.run('cat /home/user/input.txt')
    print(result.stdout)
finally:
    sandbox.kill()

Keep a sandbox between tasks

Call pause() to suspend a sandbox with its memory, processes and disk. Sandbox.connect(id) resumes the same sandbox. To pause when its timeout expires, create it with lifecycle: { onTimeout: 'pause', autoResume: false } in JavaScript, or lifecycle={'on_timeout': 'pause', 'auto_resume': False} in Python. setTimeout / set_timeout renews its deadline from now. kill() deletes it when you have finished.

The E2B SDK reference lists method mappings and protocol facts. For new integrations, workspace tools and the agent loop expose Shardflux's turn controls directly.

View this page as Markdown