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:
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
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
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()Interpreter, desktop and browser previews
@e2b/code-interpreter uses the code-interpreter-v1 alias for Python, JavaScript and TypeScript. Code contexts
keep their state between calls. @e2b/desktop uses the desktop alias for screenshots, input and its browser
stream. Both aliases download their runtime inside the sandbox on first create and need outbound package access.
For slow downloads, increase your request timeout, for example requestTimeoutMs: 240_000.
Create-time envs apply to commands, terminals and code kernels, and survive reconnects. Per-command envs
override individual values. PTY create, connect, input, resize and kill use native terminals.
New sandboxes allow public application previews at https://${sandbox.getHost(port)}. To keep app ports private,
create with network: { allowPublicTraffic: false } and send e2b-traffic-access-token: <sandbox.trafficAccessToken>
on app requests. Existing private sandboxes retain their policy. Envd and code-interpreter ports always require
authentication. See the reference for limits and unsupported methods.
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.