Skip to content

Browser

Drive the headless browser in a browser-template sandbox.

Every method shows the same operation in each SDK; pick a language once and every tab on the site follows it.

Python TypeScript Go Ruby Java

Browser drives the browser of a sandbox created from the browser template.

Python exposes these as methods; see below.

def back(self, *, max_chars: int | None=None) -> BrowserResult
Parameter Type Default
max_chars int | None None

Returns BrowserResult

Source: sdk/python/svm/browser.py:194
def browser_use_script(self, task: str, *, model: str='gpt-4o', provider: str='openai') -> str

A Python program that runs the browser-use library on this sandbox’s Chromium, attached over CDP. The API key for the provider is read from the sandbox’s environment (OPENAI_API_KEY, ANTHROPIC_API_KEY).

Parameter Type Default
task str
model str 'gpt-4o'
provider str 'openai'

Returns str

Source: sdk/python/svm/browser.py:239
def call(self, tool: str, arguments: dict[str, Any] | None=None, *, max_chars: int | None=None, timeout: float=60) -> BrowserResult

Call any tool of the Playwright MCP server by name.

Parameter Type Default
tool str
arguments dict[str, Any] | None None
max_chars int | None None
timeout float 60

Returns BrowserResult

Source: sdk/python/svm/browser.py:167
cdp_url: str

Property (read-only).

The DevTools endpoint of the sandbox’s Chromium, on the sandbox’s loopback, for browser-use and other CDP clients.

Not in the Python SDK’s Browser.

def click(self, ref: str, *, element: str='', double: bool=False, max_chars: int | None=None) -> BrowserResult

Click the element with this ref from the latest snapshot; element is a human-readable name Playwright records.

Parameter Type Default
ref str
element str ''
double bool False
max_chars int | None None

Returns BrowserResult

Source: sdk/python/svm/browser.py:201

Not in the Python SDK’s Browser.

Not in the Python SDK’s Browser.

def navigate(self, url: str, *, max_chars: int | None=None) -> BrowserResult
Parameter Type Default
url str
max_chars int | None None

Returns BrowserResult

Source: sdk/python/svm/browser.py:189
def press(self, key: str, *, max_chars: int | None=None) -> BrowserResult
Parameter Type Default
key str
max_chars int | None None

Returns BrowserResult

Source: sdk/python/svm/browser.py:220
def screenshot(self, *, full_page: bool=False) -> bytes

A PNG of the page, only when asked: this costs an image’s worth of tokens where a snapshot costs a few hundred.

Parameter Type Default
full_page bool False

Returns bytes

Raises BrowserError

Source: sdk/python/svm/browser.py:229
def select_option(self, ref: str, values: str | list[str], *, element: str='', max_chars: int | None=None) -> BrowserResult

Select values (one option or several, by value or label) in the dropdown with this ref from the latest snapshot; element is a human-readable name Playwright records, as for click.

Parameter Type Default
ref str
values str | list[str]
element str ''
max_chars int | None None

Returns BrowserResult

Source: sdk/python/svm/browser.py:211
def snapshot(self, *, max_chars: int | None=None) -> BrowserResult

The page as its accessibility tree, with a ref on every control.

Parameter Type Default
max_chars int | None None

Returns BrowserResult

Source: sdk/python/svm/browser.py:197
def tools(self) -> list[str]

Names of the tools the gateway lets the agent use (its tool rules apply).

Returns list[str]

Source: sdk/python/svm/browser.py:180
def type(self, ref: str, text: str, *, element: str='', submit: bool=False, max_chars: int | None=None) -> BrowserResult
Parameter Type Default
ref str
text str
element str ''
submit bool False
max_chars int | None None

Returns BrowserResult

Source: sdk/python/svm/browser.py:208
def use(self, task: str, *, model: str='gpt-4o', provider: str='openai', timeout_seconds: int=600) -> str

Run browser-use on task against the sandbox’s Chromium and return its final answer.

Parameter Type Default
task str
model str 'gpt-4o'
provider str 'openai'
timeout_seconds int 600

Returns str

Raises BrowserError

Source: sdk/python/svm/browser.py:263
def wait_for(self, *, text: str | None=None, gone: str | None=None, seconds: float | None=None, max_chars: int | None=None) -> BrowserResult
Parameter Type Default
text str | None None
gone str | None None
seconds float | None None
max_chars int | None None

Returns BrowserResult

Source: sdk/python/svm/browser.py:223
Python TypeScript Go Ruby Java

text is what to show the agent (for navigate, click and type it ends with the page’s new snapshot). tokens is estimated at three characters a token, which errs high. images holds screenshots, decoded.

Property Type Description
images list[bytes]
text str
truncated bool
tokens: int

Property (read-only).

Python TypeScript Go Ruby Java

The browser could not do what was asked: the gateway is not serving it, or the tool reported an error.

Python exposes these as methods; see below.

Not in the Python SDK’s BrowserError.

Not in the Python SDK’s BrowserError.