# E2B Desktop — Headless Linux Desktop for AI Computer Use > E2B Desktop is a managed cloud Linux desktop with X11, browser, file manager, terminal. Plug into Claude Computer Use or OpenAI's CUA without local Docker. ## Install Copy the content below into your project: ## Quick Use 1. `pip install e2b-desktop` 2. `Sandbox.create()` returns a desktop with `desktop.stream.get_url()` for VNC 3. Drive with `desktop.left_click(x, y)`, `desktop.write(...)`, `desktop.screenshot()` --- ## Intro E2B Desktop is a managed cloud Linux desktop — full X11 environment, Firefox, terminal, file manager — exposed via VNC and an SDK. Drop in as the target environment for Claude Computer Use or OpenAI's CUA without setting up Docker / X11 locally. Best for: production deployments of computer-using AI agents, multi-tenant SaaS where each user gets an isolated desktop. Works with: Python SDK, Claude Computer Use, any agent that drives a screen+keyboard+mouse. Setup time: 5 minutes. --- ### Spawn a desktop sandbox ```python from e2b_desktop import Sandbox with Sandbox.create() as desktop: # Get the live VNC URL (embed in iframe or watch via VNC viewer) print(desktop.stream.get_url()) # Take a screenshot screenshot = desktop.screenshot() with open("screenshot.png", "wb") as f: f.write(screenshot) # Drive mouse + keyboard desktop.left_click(500, 300) desktop.write("hello world") desktop.press("Enter") # Launch an app desktop.launch("firefox", "https://news.ycombinator.com") ``` ### Use with Claude Computer Use ```python from anthropic import Anthropic from e2b_desktop import Sandbox desktop = Sandbox.create() response = anthropic.beta.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=4096, tools=[ { "type": "computer_20241022", "name": "computer", "display_width_px": desktop.width, "display_height_px": desktop.height, } ], messages=[{"role": "user", "content": "Find the top story on HN, screenshot it"}], extra_headers={"anthropic-beta": "computer-use-2024-10-22"}, ) # Each tool call from Claude — execute against desktop: for content in response.content: if content.type == "tool_use" and content.input.get("action") == "screenshot": ss = desktop.screenshot() # ... return base64 to Claude elif content.input.get("action") == "left_click": x, y = content.input["coordinate"] desktop.left_click(x, y) # ... handle other actions ``` ### Multi-tenant pattern ```python # Each user gets their own sandbox def get_user_desktop(user_id): sandbox = Sandbox.create(timeout=3600) sandbox.set_metadata("user_id", user_id) return sandbox # Reconnect to a running sandbox by ID sandbox = Sandbox.connect(sandbox_id) ``` Sessions persist across calls — useful for "agent did some work, returned to the user, now resumes" flows. --- ### FAQ **Q: How is this different from Open Interpreter OS Mode?** A: Open Interpreter OS Mode runs on YOUR machine — your screen, your keyboard. E2B Desktop runs in the cloud — agent gets an isolated cloud desktop, your machine is uninvolved. Use OS Mode for personal automation; E2B Desktop for production / multi-tenant SaaS. **Q: Can I install custom apps in the desktop?** A: Yes — E2B Desktops use Ubuntu under the hood. Run `desktop.commands.run('apt install --yes ')` or build a custom image with `e2b template build` for fast cold starts. **Q: Does it support audio / video?** A: VNC streams the visual desktop in real time. Audio is not yet supported; video apps work for visual-only output. For audio interactions, layer a separate audio pipeline. --- ## Source & Thanks > Built by [E2B](https://github.com/e2b-dev). Licensed under Apache-2.0. > > [e2b-dev/desktop](https://github.com/e2b-dev/desktop) — ⭐ 1,500+ --- ## 快速使用 1. `pip install e2b-desktop` 2. `Sandbox.create()` 返回一个桌面,`desktop.stream.get_url()` 拿 VNC URL 3. 用 `desktop.left_click(x, y)` / `desktop.write(...)` / `desktop.screenshot()` 驱动 --- ## 简介 E2B Desktop 是托管的云 Linux 桌面 —— 完整 X11 环境、Firefox、终端、文件管理器 —— 通过 VNC 和 SDK 暴露。直接作为 Claude Computer Use 或 OpenAI CUA 的目标环境,不用本地搭 Docker / X11。适合用电脑的 AI agent 的生产部署、每个用户拿到独立桌面的多租户 SaaS。兼容 Python SDK / Claude Computer Use / 任何驱动屏幕+键盘+鼠标的 agent。装机时间 5 分钟。 --- ### 起一个桌面 sandbox ```python from e2b_desktop import Sandbox with Sandbox.create() as desktop: # 拿实时 VNC URL(嵌 iframe 或用 VNC viewer 看) print(desktop.stream.get_url()) # 截屏 screenshot = desktop.screenshot() with open("screenshot.png", "wb") as f: f.write(screenshot) # 驱动鼠标 + 键盘 desktop.left_click(500, 300) desktop.write("hello world") desktop.press("Enter") # 启动应用 desktop.launch("firefox", "https://news.ycombinator.com") ``` ### 配 Claude Computer Use ```python from anthropic import Anthropic from e2b_desktop import Sandbox desktop = Sandbox.create() response = anthropic.beta.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=4096, tools=[ { "type": "computer_20241022", "name": "computer", "display_width_px": desktop.width, "display_height_px": desktop.height, } ], messages=[{"role": "user", "content": "Find the top story on HN, screenshot it"}], extra_headers={"anthropic-beta": "computer-use-2024-10-22"}, ) # Claude 每个 tool 调用 —— 在 desktop 上执行: for content in response.content: if content.type == "tool_use" and content.input.get("action") == "screenshot": ss = desktop.screenshot() # …把 base64 返给 Claude elif content.input.get("action") == "left_click": x, y = content.input["coordinate"] desktop.left_click(x, y) # …处理其他动作 ``` ### 多租户模式 ```python # 每个用户独立 sandbox def get_user_desktop(user_id): sandbox = Sandbox.create(timeout=3600) sandbox.set_metadata("user_id", user_id) return sandbox # 通过 ID 重连到运行中的 sandbox sandbox = Sandbox.connect(sandbox_id) ``` 会话跨调用保留 —— 适合「agent 干了点活,返回给用户,现在恢复」这种流。 --- ### FAQ **Q: 跟 Open Interpreter OS Mode 啥区别?** A: Open Interpreter OS Mode 跑在你的机器上 —— 你的屏幕、你的键盘。E2B Desktop 跑在云上 —— agent 拿到隔离的云桌面,你的机器不参与。OS Mode 适合个人自动化;E2B Desktop 适合生产 / 多租户 SaaS。 **Q: 能在桌面里装自定义应用吗?** A: 能 —— E2B Desktop 底层是 Ubuntu。跑 `desktop.commands.run('apt install --yes ')`,或用 `e2b template build` 构建自定义镜像加速冷启动。 **Q: 支持音频 / 视频吗?** A: VNC 实时流可视桌面。音频还没支持;视频应用可视输出能用。要音频交互就叠一条独立的音频管道。 --- ## 来源与感谢 > Built by [E2B](https://github.com/e2b-dev). Licensed under Apache-2.0. > > [e2b-dev/desktop](https://github.com/e2b-dev/desktop) — ⭐ 1,500+ --- Source: https://tokrepo.com/en/workflows/e2b-desktop-headless-linux-desktop-for-ai-computer-use Author: E2B