All Products
Search
Document Center

Function Compute:Desktop template

Last Updated:Sep 16, 2026

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

FeatureDescription
Full desktopProvides a window manager, terminal, and file manager
GUI automationOperate desktop applications via screenshots, mouse coordinates, keyboard, and window APIs
BrowserBuilt-in Chrome, launchable to a specified URL via the application launch API
Live viewEnable a full-desktop live stream through the SDK
SDK compatibilitySupports Python e2b-desktop and TypeScript @e2b/desktop

Default configuration

This page uses the Beijing-region image at version v0.0.44:

ConfigurationDefaultDescription
Container imagefc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/desktop:v0.0.44Official Desktop image, Beijing region example
CPU4 vCPURecommended starting spec
Memory8192 MBRecommended starting spec
Note

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-dotenv

Save 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.py

Node.js

Install dependencies:

npm install e2b@^2.31.0 @e2b/desktop@2.3.1 dotenv
npm install --save-dev tsx
npm pkg set type=module

Save 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.mjs

Minimal 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.ts

Common capabilities

CapabilityPythonTypeScript
Create a sandboxSandbox.create(template=..., timeout=...)Sandbox.create(template, { timeoutMs })
Launch an applicationdesktop.launch("google-chrome", url)desktop.launch("google-chrome", url)
Waitdesktop.wait(10000)desktop.wait(10000)
Take a screenshotdesktop.screenshot()desktop.screenshot()
Move the mousedesktop.move_mouse(x, y)desktop.moveMouse(x, y)
Left-click, double-click, or right-clickleft_click() / double_click() / right_click()leftClick() / doubleClick() / rightClick()
Scrolldesktop.scroll("down", amount)desktop.scroll("down", amount)
Dragdesktop.drag((x1, y1), (x2, y2))desktop.drag([x1, y1], [x2, y2])
Type textdesktop.write("...")desktop.write("...")
Press a key or shortcutpress("enter") / press(["ctrl", "c"])press("enter") / press(["ctrl", "c"])
Get the current window IDdesktop.get_current_window_id()desktop.getCurrentWindowId()
Start or stop a live streamstream.start() / stream.stop()stream.start() / stream.stop()
Get the stream URLstream.get_url(auth_key=...)stream.getUrl({ authKey })
Kill the sandboxdesktop.kill()desktop.kill()

Usage constraints

ConstraintDescription
Resource specRecommended 4 vCPU and 8192 MB memory or higher
RegionThe image, E2B_API_URL, and E2B_DOMAIN must all use the same region
Live streamOnly 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
LifecycleCall kill() after the task completes to avoid the desktop sandbox consuming resources indefinitely