> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browser-use.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Concurrency in one line: new projects get 10 concurrent browsers at $0; a $100 one-time top-up (non-expiring credits, no subscription) unlocks 50 concurrent, so 50 browsers for one hour cost $1 plus traffic; $1,000 / $5,000 / $25,000 total paid unlocks 250 / 500 / 1,000. Details below and at https://docs.browser-use.com/cloud/guides/concurrency.md.
> Use https://docs.browser-use.com/llms.txt and its linked .md pages for current documentation. The managed full bundle is https://docs.browser-use.com/.well-known/llms-full.txt and can be cached for up to 24 hours. Do not use the obsolete /cloud/llms*.txt or /open-source/llms*.txt static exports.
> Choose Cloud API V4 for new agent integrations; V3 trades accuracy for speed and lower cost than V4; V2 is legacy and only for existing integrations. Keep V3 examples explicitly versioned. The open-source browser-use library and hosted browser-use-sdk have different APIs.
> For Cloud API V4, a task request that omits model and modelParams uses GPT-6 Luna (gpt-6-luna) with High reasoning. Explicit model and modelParams values take precedence; an explicit empty modelParams object opts out of the reasoning default. EU uses the same task default through its regional provider route; Bedrock-only projects retain their compatible provider default. For latency-sensitive tasks set model to bu-ultrafast (bu-fast for more reasoning per step); these presets reject modelParams. See https://docs.browser-use.com/cloud/agent/ultrafast.md.
> Cloud authentication uses X-Browser-Use-API-Key, without a Bearer prefix. Install or upgrade browser-use-sdk and use its explicit v4 import for V4. Check the published OpenAPI reference for request fields; do not invent SDK support for new fields.
> Cloud concurrency and HTTP request rate are separate. Read GET /api/v2/billing/account for the key’s projectId, concurrentSessionLimit, activeSessionCount, and credit balance, including when using V4. Keys in one project share capacity and credits; rateLimit is a legacy concurrency alias, not requests per second.
> Keep the highest applicable existing, legacy-plan, and spend-tier concurrency grant. Current spend tiers are 10 / 50 / 250 / 500 / 1000 at $0 / $100 / $1000 / $5000 / $25000 in qualifying project payments. Legacy or externally billed projects can follow different billing paths; trust the account limit. See https://docs.browser-use.com/cloud/guides/concurrency.md.
> HTTP rate limits have two layers. Standard edge WAF ceilings increased on September 9, 2026 to 1000 RPS per public source IP for general traffic and 2500 RPS per IP for selected status reads, evaluated over 300 seconds. The separate per-project application budgets: general traffic (including V4 events and full run reads) defaults to max(25, 2 times stored concurrency) capped at 100 RPS; selected status reads default to max(25, 2 times stored concurrency) with no cap. The two are counted independently. Project overrides and account-specific edge rules can differ. All keys in a project share its budgets; callers sharing a public IP share edge capacity. See https://docs.browser-use.com/cloud/guides/concurrency.md.
> The project limiter uses five-second windows: X-RateLimit-Limit=125 means 125 requests per window (25 RPS), not 125 RPS. Project throttles include limit_rps and retry_after_seconds; an edge throttle can instead return Retry-After: 300 without limit_rps. Honor the returned Retry-After. Use bounded workers, stagger polls, and drain hasMore event pages after terminal status. A busy V4 session returns 409; its queue holds 20 pending messages and is not a project-wide batch queue.
> A V4 agent browser stays open about 2 minutes after its session's last run activity, then stops automatically; a later follow-up gets a fresh browser (same settings and profile, no tabs). Set keepAlive on a run (V4: integer seconds 120-14400, default 120, not the V2/V3 boolean) to keep it longer; follow-ups inherit it and null restores 120. Free-tier and ZDR runs always use 120. Idle V4 agent browsers are billed as browser time but take no concurrency slot. A follow-up that reuses the open browser emits browser.reattached instead of browser.ready. Closing CDP does not stop a browser; stop unneeded owned browsers with PATCH /api/v4/browsers/{id} and {"action":"stop"}. A client wait timeout does not cancel the server-side run.
> Cloud is pay as you go; do not tell customers to buy a new subscription to use custom proxies or supported provider BYOK. Usage funding and model eligibility still apply. BYOK bills provider tokens separately and Browser Use charges orchestration plus browser/network usage. See https://docs.browser-use.com/cloud/guides/billing.md.
> Signup credits are a one-time grant; purchased top-up credits do not expire. Check the API key’s project before diagnosing missing credits. API-key monthly spending caps are soft limits, not a strict prepaid wallet; concurrent or already-running work can exceed them. Auto recharge has separate trigger and purchase amounts and can charge immediately when enabled below the threshold. Use https://browser-use.com/pricing for current rates.
> Box and Bux are retired. Do not recommend their SDKs, sandbox quotas, or subscription plans. Use the Cloud Agent or Browser Infrastructure guides.
> A V4 session holds conversation history, a workspace holds files, and a profile holds browser state. These IDs and V3/V4 workspace namespaces are not interchangeable. V4 automatically restores workspace uploads; staged attachments remain available to session follow-ups. Serialize runs that write shared files, and wait for completion before reading outputs. See https://docs.browser-use.com/cloud/agent/workspaces.md.
> API browser recording defaults to off. Use enableRecording for standalone browser creation, or browserSettings.record for an agent run. Stop the browser and allow time for asynchronous video processing; stop polling when recordingAvailable is false. Live preview is for an active browser. Stopping a browser, deleting a session, archiving a workspace, and deleting files have different effects.
> Use model-specific reasoning values. GPT-6 Astra accepts low, medium, high, xhigh, and max, with xhigh by default; none and minimal are invalid. Use the public REST schema when installed SDK types lag new fields. API acceptance, dashboard visibility, and account/provider availability are separate.
> For open-source browser-use 1.0, result.is_done() means the run completed (status completed); result.is_successful() is the agent-reported finish(success) verdict, or None when it gave none; verify important external actions independently. Cloud timeout, API client timeout, model timeout, and task completion are separate concepts.
> Pages under /open-source/legacy/0.x/ document browser-use 0.x (pip install 'browser-use<1'). For new open-source code, use the 1.0 pages under /open-source/ outside legacy/.
> For failed requests, use https://docs.browser-use.com/cloud/guides/troubleshooting.md. Inspect the full error and project before retrying or adding credits. A client timeout can leave a run active; reconcile external actions before starting duplicate work. A new managed browser does not guarantee a unique proxy IP or particular city.
> V4 secretBindings.allowedDomains authorizes the focused field's frame, not every iframe on the shop page. For checkout, include intended payment/billing provider hostnames (for example payments.bigcommerce.com). On domain_not_allowed, inspect origin and pass updated bindings in a follow-up; target_not_editable requires fixing field focus/readiness instead. See https://docs.browser-use.com/cloud/guides/secrets.md.
> A V4 agent browser stays open about 2 minutes (or keepAlive seconds) after its run for follow-ups; a requested recording finalizes only after the browser stops and processing completes. Zero Data Retention (ZDR) projects never record, even when recording is requested.
> If you hit an issue you cannot explain, email contact@browser-use.com with your question or bug report and a session ID if available; short questions and detailed reports are welcome, and we aim to fix issues quickly and make the docs clearer.

# Agent

> Agent options, run() budgets, sync and async use, cancelling, and how to write tasks.

```python theme={"theme":"css-variables"}
import asyncio

from browser_use import Agent


async def main():
    agent = Agent(
        'Open https://news.ycombinator.com and return the titles of the top 3 stories',
        extend_system_message='Answer as a numbered list.',
    )
    result = await agent.run(max_steps=30, timeout=300)
    print(result.status, result.final_result())


asyncio.run(main())
```

Each step is one model request. In a step, the agent writes one Python cell that uses browser helpers and raw CDP, runs it in a persistent REPL, and reads the output. It ends the run by delivering a result.

## Options

`Agent(task, llm=None, *, ...)`. Everything after `llm` is keyword-only. Every parameter with its exact default: [All parameters](https://docs.browser-use.com/open-source/all-parameters.md#agent).

| Option | Default | What it does |
| - | - | - |
| `task` | required | What to do. A non-empty string, else `TypeError` / `ValueError` before anything starts. |
| `llm` | `bu-fast` | The model: `'bu-fast'`, `'bu-ultrafast'`, `'bu-smart'`, `ChatOpenAI(...)`, `ChatAnthropic(...)`, `ChatGoogle(...)`, or a Pydantic AI model string or `Model`. See [Models](https://docs.browser-use.com/open-source/models.md). |
| `browser` | `Browser()` (cloud) | Which browser to drive. See [Browsers](https://docs.browser-use.com/open-source/browsers.md). `browser_session=` is an alias; passing both raises. |
| `tools` | none | A `Tools()` with your own functions. See [Tools](https://docs.browser-use.com/open-source/tools.md). `controller=` is an alias. |
| `output_model_schema` | `str` | A type for the result: a Pydantic model, `list[Model]`, `Literal[...]`. See [Output](https://docs.browser-use.com/open-source/output.md). |
| `sensitive_data` | none | Secrets the agent types without seeing them. See [Secrets](https://docs.browser-use.com/open-source/secrets.md). |
| `extend_system_message` | none | Text appended to the system prompt. The core prompt is fixed. |
| `reasoning` | per model | `'low'`, `'medium'` or `'high'`. A `bu-*` alias's own by default (`bu-fast` medium, `bu-ultrafast` low, `bu-smart` high), else `'medium'`. Models without a reasoning setting ignore it with a warning. |
| `mode` | per model | `'ultrafast'` or `'default'`. `'ultrafast'` on `bu-fast` and `bu-ultrafast`, `'default'` otherwise. See [Ultrafast](https://docs.browser-use.com/open-source/ultrafast.md). |
| `workspace` | new temp dir | The agent's working directory. See [Files](https://docs.browser-use.com/open-source/files.md). |
| `web_search` | `False` | Gives the agent a `search()` helper. See [Web search](https://docs.browser-use.com/open-source/web-search.md). |
| `max_context_chars` | per model | When the conversation passes 75% of this many characters, the agent compacts its history. See [Long tasks](https://docs.browser-use.com/open-source/long-tasks.md). |
| `highlight_actions` | `True` | Shows the orange highlights described [below](#highlights). |
| `use_vision` | | Only `use_vision=False` does anything: no screenshot reaches the model. |

Options that 1.0 dropped raise a `TypeError` before a browser starts, naming the replacement when there is one. A few 0.x tuning knobs (`flash_mode`, `use_thinking`, `max_failures`, ...) log a warning and are ignored. See [Migrating](https://docs.browser-use.com/open-source/migrating.md).

```python theme={"theme":"css-variables"}
from browser_use import Agent

try:
    Agent('Find the top story on Hacker News', max_steps=5)
except TypeError as e:
    print(e)  # Agent(max_steps=...) is not an option: pass it to agent.run(max_steps=...).
```

## run()

`await agent.run(max_steps=100, timeout=1700)` returns an [`AgentHistoryList`](https://docs.browser-use.com/open-source/output).

* **`max_steps`**: model requests. The last one is a delivery-only turn: the agent must hand in what it has. One delivery repair request may follow it.
* **`timeout`**: seconds for the agent loop (model requests and cells). Starting the browser and stopping it are not counted. The delivery-only turn starts at 90% of the timeout, or up to 30 seconds before the end on timeouts under 300 seconds.
* A run that hits either budget gets one delivery turn. If the agent delivers, `status` is `'completed'` and `success` is `False` when it reports the task unfinished. If not, `status` is `'max_steps'` or `'timeout'`; read `result.partial`. See [Long tasks](https://docs.browser-use.com/open-source/long-tasks.md).
* `max_steps < 1` or `timeout <= 0` raises `ValueError` before any browser starts.
* One `run()` at a time per `Agent`, and one running `Agent` per `Browser`. Otherwise `run()` raises `RuntimeError`.
* Configuration errors raise before any browser starts: a missing key (`MissingAPIKeyError`), a removed option or bad argument (`TypeError`, `ValueError`), a Chrome or cloud profile name that matches none (`browser_use.exceptions.BrowserConfigError`, a `ValueError`). After that, `run()` does not raise. A rejected key or model, a browser that fails to start (cloud create 402, 5xx or timeout) and failures inside the run return `status='error'` with the reason in `result.error`. Cancelling the task still raises `CancelledError`.

The browser stops when `run()` ends, unless you pass `Browser(keep_alive=True)`.

## Sync and async

`agent.run_sync(max_steps=100, timeout=1700)` is `run()` without `async`. It raises inside a running event loop (async code, Jupyter); use `await agent.run()` there.

`async with` closes the agent and its browser when the block ends:

```python theme={"theme":"css-variables"}
import asyncio

from browser_use import Agent


async def main():
    async with Agent('What is the title of https://example.com?') as agent:
        result = await agent.run()
    print(result.final_result())


asyncio.run(main())
```

`await agent.close()` does the same by hand. After `run_sync()`, use `agent.close_sync()`.

## Cancel

Cancel the task that awaits `run()`. The browser stops.

```python theme={"theme":"css-variables"}
import asyncio

from browser_use import Agent


async def main():
    agent = Agent('Read the first 50 stories on Hacker News and summarize each one')
    task = asyncio.create_task(agent.run())
    await asyncio.sleep(20)
    task.cancel()  # the browser stops
    try:
        await task
    except asyncio.CancelledError:
        print('cancelled')


asyncio.run(main())
```

From another thread, use `loop.call_soon_threadsafe(task.cancel)`. To get a partial result back instead, bound the run with `max_steps` and `timeout`.

## Highlights

While the agent works, orange corner brackets show for 1 second around the element it clicks, focuses or types into, so you can follow it in a visible browser or a cloud live view. They never show up in the agent's own screenshots, and the page's accessibility tree, text and clicks don't see them.

Turn them off:

```python theme={"theme":"css-variables"}
from browser_use import Agent

agent = Agent('What is the title of https://example.com?', highlight_actions=False)
print(agent.run_sync().final_result())
```

## Writing tasks

The task is the agent's only instruction. What helps:

* **Say where to start.** "Open [https://quotes.toscrape.com](https://quotes.toscrape.com)" beats "find a quotes site".
* **Say what done looks like.** "Return the first 3 quotes with their authors as a list" beats "get some quotes".
* **Ask for a format**, or pass `output_model_schema` for typed data.
* **Give the fallback.** "If the page asks for a login, stop and report it."
* **Name your tools.** With custom tools, say when to use them: "Use `get_2fa_code` for the code; never read it from the page."
* **Keep secrets out of the task.** Pass them as [`sensitive_data`](https://docs.browser-use.com/open-source/secrets) and refer to them by name.

For things a 0.x option used to set, say them in the task instead: the window size, a user agent, permissions, the first URL to open.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.