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
2
Set your API keys
Get your Browser Use key and OpenAI key.
3
Download and run
The complete example
The example enables all 28 browser tools and Bash.browser_use_library.py
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.
Coordinate actions and JavaScript
Coordinate actions and JavaScript
Enable every browser tool with The driver also supports
members=BROWSER_MEMBERS:run_script for approved page JavaScript.
A script timeout stops waiting; it does not guarantee that page execution stops.Existing sessions and local browsers
Existing sessions and local browsers
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.Element references and supported features
Element references and supported features
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.Permissions and custom HTTP clients
Permissions and custom HTTP clients
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.