Skip to main content
Connect OpenAI’s browser tools to Browser Use Cloud with the Browser Use library. OpenAI’s SDK runs the model loop. Our driver turns tool calls into browser actions. Browser Use Cloud runs Chromium remotely, so your application needs no local browser installation. The OpenAI model sends function calls to the OpenAI SDK's AsyncResponsesToolRunner, which passes each one to Browser Use and returns each function_call_output to the model. Browser Use provides 28 browser tools on a Browser Use Cloud browser, and Bash, which runs on your application host. The OpenAI model sends function calls to the OpenAI SDK's AsyncResponsesToolRunner, which passes each one to Browser Use and returns each function_call_output to the model. Browser Use provides 28 browser tools on a Browser Use Cloud browser, and Bash, which runs on your application host. Use this driver for all 28 browser tools. Bash runs beside your application; the browser runs in Browser Use Cloud. Use the OpenAI + Playwright guide for an existing Playwright application.

Run your first task

You need uv, a Browser Use API key, and an OpenAI API key. Choose an OpenAI model that supports Responses function tools.
1

Create a project

This command installs this driver commit with all 28 browser tools and Bash. Cloud browsers need no local Chromium installation.
2

Set your API keys

Get your Browser Use key and OpenAI key.
3

Download and run

The model follows a link and writes a source-backed summary with Bash. The driver stops its remote browser when the script finishes.
The tool runner relays the model's browser calls to the Cloud browser on example.com and its bash call to your application host, where it writes outputs/summary.md. A typical run uses the navigate, read_page, click (on Learn more), read_page, and bash tools, and native compaction shrinks the context only after it passes 60,000 tokens. The tool runner relays the model's browser calls to the Cloud browser on example.com and its bash call to your application host, where it writes outputs/summary.md. A typical run uses the navigate, read_page, click (on Learn more), read_page, and bash tools, and native compaction shrinks the context only after it passes 60,000 tokens. The example enables OpenAI’s native compaction at 60,000 tokens. Compaction reduces conversation context during long tasks. The SDK keeps control of the model loop.

The complete example

The example enables all 28 browser tools and Bash.
browser_use_library.py
The confirmation callback approves browser actions in this example. Use it only in an isolated environment for tasks you authorize. Bash runs on your application host, not inside the remote browser. Bash uses your application’s Python environment and stores temporary files under outputs/.tmp. Pass python_executable to select another Python environment. It uses a stripped environment and execution limits, but it does not provide a security sandbox.

Browser actions

The driver uses the same Browser Use Actor API as our Claude integration. OpenAI’s SDK provides list_tabs from the driver’s state. Use members=BROWSER_MEMBERS to expose all 28 browser tools. Update your confirmation callback to permit the actions your task needs. File tools move one file per grant that your application issues. Your application calls driver.grant_upload or driver.grant_download and passes the returned grant_id to the model. The model uses the upload_file or download_file tool with that grant_id, and the driver moves one file of up to 10 MB: an upload into the browser's file input, or a download to a new file on your application host. Your application calls driver.grant_upload or driver.grant_download and passes the returned grant_id to the model. The model uses the upload_file or download_file tool with that grant_id, and the driver moves one file of up to 10 MB: an upload into the browser's file input, or a download to a new file on your application host.
Enable every browser tool with members=BROWSER_MEMBERS:
The driver also supports run_script for approved page JavaScript. A script timeout stops waiting; it does not guarantee that page execution stops.
Pass a connected BrowserSession to BrowserUse(browser=session) to reuse your browser. Your application keeps responsibility for that session.Use BrowserUse() for a local browser. Install local Chromium with uvx browser-use install first.
Read the page before using an element reference. Page reads preserve references for existing elements. Navigation and detached elements can invalidate references.Page reads preserve the main document’s accessibility tree, including hierarchy, control states, and field values. Page reads, page text, and JavaScript results stop at 10,000 characters and report truncation. Use scoped reads or find for specific content. find searches the complete tree before limiting its output. The driver retries page reads and screenshots once after a failure. It reconnects once when browser state fails. Persistent state failures still stop the OpenAI runner. It does not replay clicks or typing after uncertain effects. Page reads do not guarantee complete iframe or shadow-root coverage. Use screenshots and coordinate actions when necessary.Scoped reads discover page regions and return references for their controls. Diagnostics capture console messages and network responses after the driver first accesses a tab. Network reports exclude query strings, headers, and request bodies.File tools require application-issued grants. Your application calls await driver.grant_upload(path, target=ref, tab_id=tab_id) for an approved upload. Your application calls await driver.grant_download(url, path, tab_id=tab_id) for an approved download. Pass the returned grant ID to the model for its upload_file or download_file call.Each grant permits one transfer in the original document. Uploads capture the approved file bytes when your application creates the grant. Downloads create a new file on your application host. Both tools support files up to 10 MB (10,000,000 bytes). Enabling file tools does not create file grants automatically. Downloads use browser fetch and follow browser cross-origin rules. Downloads reject redirects. Uploads use the page’s file input and dispatch input and change events.
The toolset checks inputs and calls your confirmation callback before actions. The URL callback checks requested navigation; it does not replace network controls.OpenAI 3.x uses httpx2. Use OpenAI’s DefaultAsyncHttpxClient for custom HTTP clients.
See the OpenAI browser helper reference.