Skip to main content
Use CoreWeave Sandbox to give an agent a Linux desktop it can operate through screenshots, mouse clicks, and keyboard input. This tutorial runs Chromium in a disposable serverless sandbox. A Python controller on your machine sends desktop screenshots to OpenAI’s computer tool, executes the returned actions in the sandbox, and retrieves the results. Have the agent complete a sample browser form. The form’s server independently verifies the submission, so success doesn’t depend only on the model’s completion report.

Prerequisites

Before you begin, make sure you have the following:
  • Python 3.11, 3.12, or 3.13 and uv.
  • A CoreWeave API access token with sandbox access. See Choose a credential.
  • An OpenAI API key with access to gpt-5.6-sol and the computer tool.
  • Outbound access from your controller to the sandbox service and the OpenAI API. The sandbox installs packages from Debian repositories.
The example requests 2 CPUs and 4 gibibytes (GiB) of memory, with a 30-minute maximum sandbox lifetime. It explicitly selects serverless placement, so you don’t need to deploy a runner.

Configure credentials

Create a working directory and start Bash for the hidden-input prompts:
In that shell, enter your CoreWeave and OpenAI credentials:
Both keys stay in the local controller environment. The script doesn’t pass them to the sandbox. The controller sends desktop screenshots and the task prompt to the model API.

Create the desktop controller

In your working directory, save the following complete example as the computer_use.py file. It combines three components: Chromium runs as the desktop user with its browser sandbox enabled. The form server listens on loopback inside the sandbox. This example doesn’t create a public endpoint or open a browser on your machine. The adapter validates coordinates and key combinations and passes typed text as a literal argument. The loop stops on unsupported actions or a requested safety review. It permits up to 20 model turns and checks a 10-minute deadline between turns.
computer_use.py

Run and verify the task

From the same shell, run the controller with its dependencies:
The controller creates a sandbox, installs the desktop packages, and waits for Chromium to load the form. The model then reads the page, enters the displayed phrase, and selects Verify. Package installation can take several minutes. The number of model turns can vary. Each run saves its results in a new directory under computer-use-results/: After a successful run, the result.json file contains "status": "passed", "verified": true, and "cleanup": "stopped". To see PASS on the form, open the agent/final.png file. The controller checks the form server’s verification file before declaring success. The controller attempts to stop the sandbox in a finally block, including when the task fails. If cleanup reports "failed" or you terminate the controller before cleanup finishes, use the ID from the sandbox-id.txt file to stop it. Replace [SANDBOX-ID] with that ID. In the same shell, stop the sandbox:
If the task fails, inspect the saved transcript and the latest agent/turn-*.png file if available. API, desktop installation, and browser startup failures can occur before one or both files exist. For sandbox connection and execution errors, see Troubleshooting.

Next steps

To adapt the example, replace the sample form and task with an application you control. Keep the screenshot/action loop and add an application-specific success check. For repeated runs, build the desktop packages into a container image to avoid installing them at startup. See Sandbox configuration. Before you use the agent with other applications, define allowed destinations and actions, and require human approval for sensitive operations. The sample prompt and input validation don’t enforce where Chromium can navigate. When you extend the controller, review OpenAI’s computer-use guidance. For more ways to connect an agent to a sandbox, see Agents. For lifecycle management, see Cleanup patterns.
Last modified on September 25, 2026