E2B SDK-compatible API List

更新时间:
复制 MD 格式

This topic describes the main capability boundaries that FC Agent Sandbox currently provides through E2B SDK and CLI compatibility. FC Agent Sandbox does not currently provide a standalone SDK or OpenAPI. As a result, the "APIs" in this topic refer to E2B SDK object methods and E2B CLI commands, not FC-native OpenAPI definitions.

Keep the following three points in mind when reading this topic:

  • Method names and parameter shapes depend on the E2B SDK version you are using. Python and TypeScript may follow different naming styles.

  • Capabilities marked as compatible still need to be validated against account quotas, region availability, template status, and SDK version.

  • Capabilities marked as limited or unsupported should not be treated as the primary production integration path.

Sandbox

Sandbox is the core object in FC Agent Sandbox. The current primary path is to use the E2B SDK to create, connect to, inspect, pause, resume, set timeouts for, and terminate sandboxes.

Compatible capabilities:

  • Create a sandbox: Sandbox.create().

  • Connect to an existing sandbox: Sandbox.connect(sandboxId).

  • List sandboxes: Sandbox.list().

  • Query sandbox information: Sandbox.getInfo(sandboxId), sandbox.getInfo().

  • Check runtime status: sandbox.isRunning().

  • Set timeouts: Sandbox.setTimeout(sandboxId, ms), sandbox.setTimeout(ms).

  • Pause a sandbox (requires allowlist access): sandbox.pause().

  • Terminate a sandbox: Sandbox.kill(sandboxId), sandbox.kill().

  • Get file upload and download URLs: sandbox.uploadUrl(path), sandbox.downloadUrl(path).

  • Get a port access address: sandbox.getHost(port).

Usage recommendations:

  • Business code should release sandboxes in try/finally blocks to avoid leaving resources allocated after task failures.

  • Sandbox.connect(sandboxId) is suitable for resuming or taking over an existing sandbox. The connection fails if the target sandbox has already been terminated, reclaimed due to timeout, or belongs to a different account or region.

  • Port access is suitable for previewing temporary web services. It should not directly replace a formal API gateway, authentication, or traffic governance.

Commands

Commands is used to run commands inside a sandbox, manage background processes, and handle input and output.

Compatible capabilities:

  • Run a command: sandbox.commands.run().

  • List commands or processes: sandbox.commands.list().

  • Connect to a background command: sandbox.commands.connect().

  • Send stdin to a command: sandbox.commands.sendStdin().

  • Kill a command: sandbox.commands.kill().

  • Interactive terminals: use the independent sandbox.pty API.

Usage recommendations:

  • Use commands.run() for standard batch commands whenever possible. Use sandbox.pty only for interactive CLIs, colored output, progress bars, or commands that depend on TTY detection.

  • For long-running tasks, set command-level timeouts and process stdout and stderr instead of waiting only for the final result.

  • Do not concatenate unvalidated user input directly into shell commands.

Filesystem

Filesystem is used to read and write files and manage directories during the sandbox lifecycle.

Compatible capabilities:

  • List a directory: sandbox.files.list().

  • Check whether a path exists: sandbox.files.exists().

  • Get file or directory metadata: sandbox.files.getInfo() / sandbox.files.get_info().

  • Read a file: sandbox.files.read().

  • Write a file: sandbox.files.write().

  • Create a directory: sandbox.files.makeDir().

  • Delete a file or directory: sandbox.files.remove().

  • Rename a file or directory: sandbox.files.rename().

  • Watch a directory: sandbox.files.watchDir() / sandbox.files.watch_dir().

Usage recommendations:

  • FC Agent Sandbox does not currently support custom file metadata. Even when the SDK's files.write() signature accepts metadata, the call can fail before the request is sent because the sandbox runs an envd version earlier than 0.6.2. Regular file reads and writes are unaffected.

  • Directory watching is useful for waiting for file generation or syncing task artifacts. If you only need to wait for a single file, bounded polling with exists() also works.

  • The local sandbox filesystem is suitable for temporary task files, not for long-term persistent storage.

  • Data that must be retained, shared, or preserved across sandboxes should be written to external storage such as NAS or OSS.

  • When handling user-uploaded paths, restrict writable directories and file sizes to avoid path traversal and resource exhaustion.

Code Interpreter

Code Interpreter is used to execute code snippets and preserve context across multiple executions.

Compatible capabilities:

  • Run code: sandbox.runCode() / sandbox.run_code().

  • Create an execution context: sandbox.createCodeContext() / sandbox.create_code_context().

  • Query execution contexts: sandbox.listCodeContexts() / sandbox.list_code_contexts().

  • Restart execution contexts: sandbox.restartCodeContext() / sandbox.restart_code_context().

  • Delete execution contexts: sandbox.removeCodeContext() / sandbox.remove_code_context().

  • Retrieve execution output, including stdout, stderr, execution count, expression results, and rich results in execution.results.

  • Receive stdout, stderr, and result callbacks.

  • Run Python, JavaScript, TypeScript, and Bash through the language parameter. Java and R are not supported.

  • Preserve variables and execution state within the same context.

Usage recommendations:

  • Code Interpreter is suitable for data analysis, code interpreter, and notebook-style tasks.

  • If the task is closer to fixed-script execution, Commands is easier for auditing, timeout control, and output validation.

  • Do not allow code to access arbitrary paths, arbitrary networks, or unlimited resources by default.

Templates

Templates are used to define reusable runtime environments. The current primary path is to reuse built-in templates or build custom templates, and then create sandboxes through the SDK or CLI.

Compatible capabilities:

  • Query templates.

  • Create, update, or delete templates.

  • Build templates.

  • Manage templates by tags, versions, or aliases.

  • Create sandboxes from templates.

Usage recommendations:

  • In production, pin the template name, version, or alias. Avoid uncontrolled changes caused by references such as latest.

  • Preinstall language runtimes, system dependencies, base CLIs, and stable business SDKs in the template to reduce per-sandbox runtime installation.

  • Template builds depend on image registries, networks, and account permissions. If a build fails, check those prerequisites before troubleshooting SDK parameters.

CLI

FC Agent Sandbox is compatible with the commonly used E2B CLI commands for debugging and management. The CLI is suitable for local validation, troubleshooting, and lightweight operations. It should not be used as the primary control plane for production systems.

Compatible commands:

  • View templates: e2b template list.

  • Create a sandbox: e2b sandbox create.

  • View sandboxes: e2b sandbox list.

  • Terminate a sandbox: e2b sandbox kill <sandbox-id>.

  • Connect to a sandbox: e2b sandbox connect <sandbox-id>.

  • Execute a command: e2b sandbox exec <sandbox-id> <command>.

  • View metrics: e2b sandbox metrics <sandbox-id>.

Configuration requirements:

export E2B_API_KEY="<your-api-key>"
export E2B_API_URL="https://api.<region>.e2b.fc.aliyuncs.com"
export E2B_DOMAIN="<region>.e2b.fc.aliyuncs.com"

E2B_ACCESS_TOKEN is a deprecated legacy E2B authentication variable. New E2B CLI versions should use E2B_API_KEY. CLI parameters may change between versions. If command behavior does not match the documentation, first run e2b --version and the target command with --help to confirm the installed CLI version and parameter shape.

Limited capabilities

The following E2B SDK capabilities currently exist only to preserve invocation compatibility or return placeholder results, and they should not be used as production dependencies:

  • Sandbox Logs: may return empty results. Do not use for formal log collection.

  • Network Config Update: may return success without applying any actual network changes. Do not use for dynamic network governance.

Sandbox Metrics currently supports viewing CPU and memory metrics. Disk and page-cache fields return placeholder values and should not be used for capacity decisions. Metrics return at 1-minute granularity. Use the Function Compute console, CloudMonitor, or Simple Log Service as the source of truth for billing, alerting, and capacity governance.

If your workload requires logs, network changes, VPC connectivity, or access to cloud storage, design those capabilities separately according to the currently available FC Agent Sandbox capabilities and Alibaba Cloud infrastructure options. Do not copy the E2B API design directly.

Capabilities not currently supported

The following capabilities are not currently part of the FC Agent Sandbox E2B compatibility path:

  • Snapshots.

  • Volume API.

  • Team management.

  • API key and access token management.

  • E2B-hosted MCP Gateway.

  • E2B custom domains, proxy tunnels, Bring Your Own Cloud, and other platform-side capabilities.

When migrating an existing E2B application, first identify whether it depends on any of these capabilities. If it does, adjust the architecture or confirm whether FC Agent Sandbox provides an alternative before starting the integration.