The Desktop template provides a complete Linux desktop environment with a built-in Chrome browser and is compatible with the e2b-desktop / @e2b/desktop SDK. You can capture screenshots to perceive the desktop, operate GUI applications with mouse and keyboard, and observe execution via live streaming.
Compared with the Browser template, the Desktop template controls an entire virtual desktop rather than driving a browser exclusively through CDP. This page covers image configuration, template building, and minimal verification. For full mouse/keyboard operations, live streaming, and security recommendations, see Use Computer Use Sandbox.
Features
| Feature | Description |
| Full desktop | Provides a window manager, terminal, and file manager |
| GUI automation | Operate desktop applications via screenshots, mouse coordinates, keyboard, and window APIs |
| Browser | Built-in Chrome, launchable to a specified URL via the application launch API |
| Live view | Enable a full-desktop live stream through the SDK |
| SDK compatibility | Supports Python e2b-desktop and TypeScript @e2b/desktop |
Default configuration
This page uses the Beijing-region image at version v0.0.44:
| Configuration | Default | Description |
| Container image | fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/desktop:v0.0.44 | Official Desktop image, Beijing region example |
| CPU | 4 vCPU | Recommended starting spec |
| Memory | 8192 MB | Recommended starting spec |
When building a template, the image registry region must match the FC Agent Sandbox access region. For other regions, replace the region segment in the image URL accordingly and keep the version tag v0.0.44. Also configure E2B_API_URL and E2B_DOMAIN for the same region.
Build the Desktop template
The Desktop template is not a ready-to-use built-in template. You must first build a named custom template from the official Desktop image. No start command or ready command is needed — the Desktop SDK automatically starts the desktop environment and live streaming service.
Python
Install dependencies:
uv venv .venv --python 3.12
source .venv/bin/activate
uv pip install e2b-desktop==2.4.1 python-dotenvSave the following code as build.py:
"""Desktop template build example."""
from dotenv import load_dotenv
from e2b import Template, default_build_logger
load_dotenv()
# The SDK automatically reads E2B_API_KEY / E2B_API_URL / E2B_DOMAIN from environment variables.
FROM_IMAGE = "fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/desktop:v0.0.44"
build = Template.build(
Template().from_image(FROM_IMAGE),
name="my-desktop-template",
cpu_count=4,
memory_mb=8192,
on_build_logs=default_build_logger(),
)
print(f"template_id: {build.template_id}")Run the build:
python build.pyNode.js
Install dependencies:
npm install e2b@^2.31.0 @e2b/desktop@2.3.1 dotenv
npm install --save-dev tsx
npm pkg set type=moduleSave the following code as build.mjs:
// Desktop template build example.
import "dotenv/config";
import { Template, defaultBuildLogger } from "e2b";
const FROM_IMAGE =
"fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/desktop:v0.0.44";
const build = await Template.build(
Template().fromImage(FROM_IMAGE),
"my-desktop-template",
{
cpuCount: 4,
memoryMB: 8192,
onBuildLogs: defaultBuildLogger(),
},
);
console.log(`template_id: ${build.templateId}`);Run the build:
node build.mjsMinimal verification
After the template is built, create a sandbox, launch Chrome, and take a screenshot to verify the desktop environment and application launch capability.
Python:
from pathlib import Path
from dotenv import load_dotenv
from e2b_desktop import Sandbox
load_dotenv()
desktop = None
try:
desktop = Sandbox.create(template="my-desktop-template", timeout=600)
desktop.launch("google-chrome", "https://example.com")
# Wait for the application window to render before taking the screenshot.
desktop.wait(10000)
Path("desktop.png").write_bytes(desktop.screenshot())
finally:
if desktop is not None:
desktop.kill()TypeScript: Save the following code as desktop.ts.
import "dotenv/config";
import { writeFileSync } from "node:fs";
import { Sandbox } from "@e2b/desktop";
let desktop: Sandbox | undefined;
try {
desktop = await Sandbox.create("my-desktop-template", { timeoutMs: 600_000 });
await desktop.launch("google-chrome", "https://example.com");
// Wait for the application window to render before taking the screenshot.
await desktop.wait(10_000);
writeFileSync("desktop.png", await desktop.screenshot());
} finally {
await desktop?.kill();
}Run the example:
npx tsx desktop.tsCommon capabilities
| Capability | Python | TypeScript |
| Create a sandbox | Sandbox.create(template=..., timeout=...) | Sandbox.create(template, { timeoutMs }) |
| Launch an application | desktop.launch("google-chrome", url) | desktop.launch("google-chrome", url) |
| Wait | desktop.wait(10000) | desktop.wait(10000) |
| Take a screenshot | desktop.screenshot() | desktop.screenshot() |
| Move the mouse | desktop.move_mouse(x, y) | desktop.moveMouse(x, y) |
| Left-click, double-click, or right-click | left_click() / double_click() / right_click() | leftClick() / doubleClick() / rightClick() |
| Scroll | desktop.scroll("down", amount) | desktop.scroll("down", amount) |
| Drag | desktop.drag((x1, y1), (x2, y2)) | desktop.drag([x1, y1], [x2, y2]) |
| Type text | desktop.write("...") | desktop.write("...") |
| Press a key or shortcut | press("enter") / press(["ctrl", "c"]) | press("enter") / press(["ctrl", "c"]) |
| Get the current window ID | desktop.get_current_window_id() | desktop.getCurrentWindowId() |
| Start or stop a live stream | stream.start() / stream.stop() | stream.start() / stream.stop() |
| Get the stream URL | stream.get_url(auth_key=...) | stream.getUrl({ authKey }) |
| Kill the sandbox | desktop.kill() | desktop.kill() |
Usage constraints
| Constraint | Description |
| Resource spec | Recommended 4 vCPU and 8192 MB memory or higher |
| Region | The image, E2B_API_URL, and E2B_DOMAIN must all use the same region |
| Live stream | Only one full-desktop Desktop stream can be active per sandbox at a time; specifying a single window is not supported in version v0.0.44 |
| Lifecycle | Call kill() after the task completes to avoid the desktop sandbox consuming resources indefinitely |