Java client library for E2B Sandbox management, providing both control plane (sandbox lifecycle) and data plane (runtime
operations) APIs.
<dependency>
<groupId>io.openkruise</groupId>
<artifactId>agents-client-e2b</artifactId>
<version>0.1.0</version>
</dependency>
| Class |
Description |
ConnectionConfig |
Connection configuration with Builder pattern, supports environment variables, custom OkHttpClient |
SandboxApi |
Control plane: create, connect, list, kill, pause, setTimeout |
Sandbox |
Data plane entry: commands, files, codeInterpreter |
SandboxInfo |
Immutable sandbox information returned by list/getInfo |
import io.openkruise.agents.client.e2b.*;
// Reads E2B_API_KEY and E2B_DOMAIN from environment variables
ConnectionConfig config = new ConnectionConfig.Builder().build();
SandboxApi api = new SandboxApi(config);
// Create → Use → Close connection + Explicitly kill sandbox
Sandbox sandbox = api.create("code-interpreter");
try (sandbox) {
sandbox.commands.run("echo hello");
sandbox.files.writeText("/tmp/demo.txt", "Hello!");
} finally {
api.kill(sandbox.getSandboxID());
}
| Variable |
Description |
E2B_API_KEY |
API key for authentication |
E2B_DOMAIN |
E2B API domain (default: your.domain.com) |