Skip to main content
The computer tool in the OpenAI Responses API lets a model operate a graphical desktop: it reads a screenshot, returns mouse and keyboard actions, and your code runs them and sends back the next screenshot. Point that loop at a superserve/desktop sandbox so the model works an isolated Linux desktop (xfce and Google Chrome) instead of your machine. Each model turn is one desktop.step request: the sandbox runs the actions and returns the screen after them.

Setup

Run the agent loop

The script creates a desktop sandbox, sends the task with the computer tool, and then answers each computer_call with a screenshot taken after its actions ran. It stops when the model replies with text, and kills the sandbox at the end. The TypeScript sample uses top-level await, so it must run as an ES module: save it as agent.mts (or set "type": "module" in package.json) and run it with npx tsx agent.mts.
The display starts at 1280x800 and the loop sends screenshots at that size, so the model’s coordinates land on the screen as they are, with no scaling. waitForChange / wait_for_change with quietMs / quiet_ms returns the first frame after the screen repainted and then stayed still for 300 ms, so the model sees the result of its actions instead of a frame from the middle of a repaint. Set MODEL to any model your OpenAI project can use with the computer tool.

How actions map to the desktop

The sandbox reads key names such as ENTER, CTRL, ALT, TAB, and F2 without regard to case. KEYS renames the few that the model spells differently. Clicks with the back or forward button and actions that hold modifier keys throw an error; add them to toDesktopActions / to_desktop_actions if your tasks need them. The desktop API lists every action the sandbox accepts.

Watch it live

getStreamUrl / get_stream_url returns a browser URL for the desktop viewer. The script creates the sandbox with the private preview policy, so that URL carries a signed credential that expires after 60 seconds. On first open, the viewer moves the credential into a cookie and drops it from the address bar. Until then, treat the URL as a secret, and mint a fresh one for each viewer. viewOnly / view_only stops that viewer from sending input, but anyone who has the URL can open it without the flag, so keep the policy private when the screen shows anything sensitive.

Safety

  • Everything the model reads from the screen is untrusted input: web pages, files, and dialogs can carry instructions aimed at the model. Keep credentials and personal data out of the desktop.
  • The model calls run in your code, not in the sandbox, so the sandbox needs to reach only the sites the task uses. Restrict everything else with network rules.
  • A computer_call can carry pending_safety_checks. The script stops on them. To continue after a person reviews the checks, send them back as acknowledged_safety_checks on the next computer_call_output.
  • Keep a person in the loop before actions with an outside effect, such as sending a message, submitting a form, or making a purchase.

Use computer-use-preview

The loop above targets the computer tool. An integration built on the older computer-use-preview model changes the request as follows: actionsOf / actions_of already reads both shapes, so only the request parameters change.