Skip to main content

modal-computer-use

modal-computer-use turns a Modal Sandbox into a remotely controllable Linux desktop through a typed, provider-neutral Python SDK and an in-Sandbox daemon.

This is an independent project using Modal.

Quick start

Use Python 3.12 or later and uv. Install the Modal extra from PyPI:

uv add "modal-computer-use[modal]"

The Modal extra supports the Modal 1.5 line and requires Modal 1.5.2 or later.

Save this as quickstart.py:

from modal_computer_use import (
    BrowserConfig,
    ComputerConfig,
    ComputerSandbox,
    ResourceConfig,
)

config = ComputerConfig(
    resources=ResourceConfig(profile="browser"),
    browser=BrowserConfig(kind="chromium"),
)

with ComputerSandbox.create(config=config) as computer:
    computer.browser.open_url("https://example.com")
    computer.mouse.move(320, 240)
    screenshot = computer.screenshots.full()
    screenshot.save("screenshot.png")
    print(screenshot.width, screenshot.height, screenshot.sha256)

Run it:

uv run python quickstart.py

When the with block ends, the SDK terminates the Sandbox and closes the connection.

Core API

ComputerSandbox is the primary synchronous entry point. AsyncComputerSandbox provides native async Modal creation, attachment, and named acquisition with the same ownership rules; see the async owner example. AsyncDaemonClient connects to an existing daemon without blocking the event loop.

Task Representative API
Create or attach ComputerSandbox.create(), ComputerSandbox.attach(), AsyncComputerSandbox.create(), AsyncComputerSandbox.attach()
Acquire by name ComputerSandbox.attach_or_create(name=...), AsyncComputerSandbox.attach_or_create(name=...)
Input computer.mouse.move(), computer.keyboard.type(), computer.clipboard.get_text()
Observe computer.screenshots.full(), computer.display.info(), computer.windows.list()
Browser and apps computer.browser.open_url(), computer.apps.launch()
Execute computer.actions.run(), computer.commands.run()
Files and recordings computer.artifacts.download(), computer.recordings.start()
Operate computer.lifecycle.status(), computer.processes.logs(name)

Action batches validate the full request before execution. They stop on the first error by default, can opt into continue_on_error, and can capture a trailing screenshot in the same request.

Inside an active ComputerSandbox:

batch = computer.actions.run(
    [
        {"type": "move", "x": 320, "y": 240},
        {"type": "click", "x": 320, "y": 240},
    ],
    screenshot_after=True,
)

batch.screenshot contains the trailing observation when the batch succeeds.

See the API guide for namespace semantics and the generated OpenAPI schema for HTTP request and response shapes.

How it works

ComputerSandbox.create() starts a new Modal Sandbox. If you use it in a with block, the SDK terminates the Sandbox automatically when the block ends. ComputerSandbox.attach() connects to an existing Sandbox. Leaving an attached with block closes the SDK connection but keeps the Sandbox running.

ComputerSandbox.attach_or_create(name=...) and its async counterpart acquire a compatible live Sandbox with that app-scoped name, or create one if it is missing. If the call creates the Sandbox, leaving the block terminates it. If the Sandbox already existed, leaving the block keeps it running.

A daemon inside the Sandbox executes desktop actions, captures screenshots and recordings, runs commands, and reads or writes files through computer.artifacts.

Performance

Warm-operation p50 latency on July 30, 2026. Modal optimized recorded the lowest p50 in each of six displayed rows; configurations and caller topologies differed.

The figure shows July 2026 p50 latency for six computer-use cases, based on 30 successful samples per cell. Lower is better. Note that warm-operation latency starts after the desktop and client connection are ready.

The detailed report gives p95 results and explains how each path was configured and measured.

Examples

Workflow Example
Configure and prewarm a browser browser_profile.py
Acquire one named desktop from async code async_named_desktop.py
Attach without taking lifecycle ownership attach_existing_sandbox.py
Capture and download a recording recording_lifecycle.py
Persist artifacts with a Modal Volume volume_artifacts.py
Hand a desktop to a Modal Function modal_function_session_handoff.py
Run an application-owned model loop OpenAI · Anthropic

Documentation

Guide What it covers
Documentation map Every maintained guide, grouped by task.
Modal deployment Sandbox lifecycle, readiness, Function handoff, warm capacity, and cleanup.
Modal optimization Production guidance for caller placement, connection reuse, async orchestration, and per-turn work.
Performance and benchmarking Latency mechanisms, tuning evidence, benchmark commands, and publication rules.
OpenAI adapter and Anthropic adapter Provider action and screenshot translation for application-owned model loops.
Contributing Development setup, required checks, and pull request expectations.

Local development

See the local development guide for daemon startup, mock and X11 backends, synchronous and async clients, authentication, and repository checks.

Security

The daemon can control the desktop and access clipboard contents, screenshots, recordings, and artifacts. Do not expose it without authentication.

See the security policy for reporting vulnerabilities and the runtime security guide for deployment guidance.

Metadata

Release files for modal-computer-use 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modal-computer-use 1.1.0
File Size Uploaded
modal_computer_use-1.1.0.tar.gz 386.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modal-computer-use 1.1.0
File Interpreter ABI Platform
modal_computer_use-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 863.0 kB

Release history Release notifications | RSS feed

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

This release

1.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page