# Computer use

Build a computer-using agent that can perform tasks on your behalf.

**Computer use** is a practical application of our Computer-Using Agent (CUA)
model, `computer-use-preview`, which combines the vision capabilities of
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o) with advanced reasoning
to simulate controlling computer interfaces and performing tasks.

Computer use is available through the
[Responses API](https://platform.openai.com/docs/guides/responses-vs-chat-completions).
It is not available on Chat Completions.

Computer use is in beta. Because the model is still in preview and may be
susceptible to exploits and inadvertent mistakes, we discourage trusting it in
fully authenticated environments or for high-stakes tasks. See
[limitations](https://platform.openai.com/docs/guides/tools-computer-use#limitations)
and
[risk and safety best practices](https://platform.openai.com/docs/guides/tools-computer-use#risks-and-safety)
below. You must use the Computer Use tool in line with OpenAI's Usage Policy and
Business Terms.

## How it works

The computer use tool operates in a continuous loop. It sends computer actions,
like `click(x,y)` or `type(text)`, which your code executes on a computer or
browser environment and then returns screenshots of the outcomes back to the
model.

In this way, your code simulates the actions of a human using a computer
interface, while our model uses the screenshots to understand the state of the
environment and suggest next actions.

This loop lets you automate many tasks requiring clicking, typing, scrolling,
and more. For example, booking a flight, searching for a product, or filling out
a form.

Refer to the
[integration section](https://platform.openai.com/docs/guides/tools-computer-use#integration)
below for more details on how to integrate the computer use tool, or check out
our sample app repository to set up an environment and try example integrations.

[CUA sample app](https://github.com/openai/openai-cua-sample-app)

## Setting up your environment

Before integrating the tool, prepare an environment that can capture screenshots
and execute the recommended actions. We recommend using a sandboxed environment
for safety reasons.

In this guide, we'll show you examples using either a local browsing environment
or a local virtual machine, but there are more example computer environments in
our sample app.

Set up a local browsing environment

If you want to try out the computer use tool with minimal setup, you can use a
browser automation framework such as Playwright or Selenium.

Running a browser automation framework locally can pose security risks. We
recommend the following setup to mitigate them:

- Use a sandboxed environment
- Set `env` to an empty object to avoid exposing host environment variables to
  the browser
- Set flags to disable extensions and the file system

#### Start a browser instance

You can start browser instances using your preferred language by installing the
corresponding SDK.

For example, to start a Playwright browser instance, install the Playwright SDK:

- Python: `pip install playwright`
- JavaScript: `npm i playwright` then `npx playwright install`

Then run the following code:

```javascript
import { chromium } from "playwright";

const browser = await chromium.launch({
  headless: false,
  chromiumSandbox: true,
  env: {},
  args: ["--disable-extensions", "--disable-file-system"],
});
const page = await browser.newPage();
await page.setViewportSize({ width: 1024, height: 768 });
await page.goto("https://bing.com");

await page.waitForTimeout(10000);

browser.close();
```

```python
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        headless=False,
        chromium_sandbox=True,
        env={},
        args=[
            "--disable-extensions",
            "--disable-file-system"
        ]
    )
    page = browser.new_page()
    page.set_viewport_size({"width": 1024, "height": 768})
    page.goto("https://bing.com")

    page.wait_for_timeout(10000)
```

Set up a local virtual machine

If you'd like to use the computer use tool beyond just a browser interface, you
can set up a local virtual machine instead, using a tool like Docker. You can
then connect to this local machine to execute computer use actions.

#### Start Docker

If you don't have Docker installed, you can install it from their website. Once
installed, make sure Docker is running on your machine.

#### Create a Dockerfile

Create a Dockerfile to define the configuration of your virtual machine.

Here is an example Dockerfile that starts an Ubuntu virtual machine with a VNC
server:

```json
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive