Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
More examples
Magnus Müllerdc5d06d7609d
diff --git a/docs/customize/browser-keep-open.mdx b/docs/customize/chain-agents.mdxsimilarity index 100%rename from docs/customize/browser-keep-open.mdxrename to docs/customize/chain-agents.mdxdiff --git a/docs/customize/fast-agent.mdx b/docs/customize/fast-agent.mdxnew file mode 100644index 000000000..3fcd3352c--- /dev/null+++ b/docs/customize/fast-agent.mdx@@ -0,0 +1,109 @@+---+title: "Fast Agent"+description: "Optimize agent performance for maximum speed and efficiency."+icon: "bolt"+mode: "wide"+---++## Fast Agent Example++This example demonstrates speed optimization techniques to create ultra-fast agents. Perfect for time-sensitive tasks or high-volume automation.++```python+import asyncio+import os+import sys++# Add the parent directory to the path so we can import browser_use+sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))++from dotenv import load_dotenv++load_dotenv()+++from browser_use import Agent, BrowserProfile++# Speed optimization instructions for the model+SPEED_OPTIMIZATION_PROMPT = """+SPEED OPTIMIZATION INSTRUCTIONS:+- Be extremely concise and direct in your responses+- Get to the goal as quickly as possible+- Use multi-action sequences whenever possible to reduce steps+"""+++async def main():+ # 1. Use fast LLM - Llama 4 on Groq for ultra-fast inference+ from browser_use import ChatGroq++ llm = ChatGroq(+ model='meta-llama/llama-4-maverick-17b-128e-instruct',+ temperature=0.0,+ )+ # from browser_use import ChatGoogle++ # llm = ChatGoogle(model='gemini-2.5-flash')++ # 2. Create speed-optimized browser profile+ browser_profile = BrowserProfile(+ minimum_wait_page_load_time=0.1,+ wait_between_actions=0.1,+ headless=False,+ )++ # 3. Define a speed-focused task+ task = """+ 1. Go to reddit https://www.reddit.com/search/?q=browser+agent&type=communities+ 2. Click directly on the first 5 communities to open each in new tabs+ 3. Find out what the latest post is about, and switch directly to the next tab+ 4. Return the latest post summary for each page+ """++ # 4. Create agent with all speed optimizations+ agent = Agent(+ task=task,+ llm=llm,+ flash_mode=True, # Disables thinking in the LLM output for maximum speed+ browser_profile=browser_profile,+ extend_system_message=SPEED_OPTIMIZATION_PROMPT,+ )++ await agent.run()+++if __name__ == '__main__':+ asyncio.run(main())+```++## Speed Optimization Techniques++### 1. Fast LLM Models+```python+# Groq - Ultra-fast inference+from browser_use import ChatGroq+llm = ChatGroq(model='meta-llama/llama-4-maverick-17b-128e-instruct')++# Google Gemini Flash - Optimized for speed+from browser_use import ChatGoogle+llm = ChatGoogle(model='gemini-2.5-flash')+```++### 2. Browser Optimizations+```python+browser_profile = BrowserProfile(+ minimum_wait_page_load_time=0.1, # Reduce wait time+ wait_between_actions=0.1, # Faster action execution+ headless=True, # No GUI overhead+)+```++### 3. Agent Optimizations+```python+agent = Agent(+ task=task,+ llm=llm,+ flash_mode=True, # Skip LLM thinking process+ extend_system_message=SPEED_PROMPT, # Optimize LLM behavior+)+```diff --git a/docs/customize/browser-multiple.mdx b/docs/customize/parallel-browser.mdxsimilarity index 100%rename from docs/customize/browser-multiple.mdxrename to docs/customize/parallel-browser.mdxdiff --git a/docs/development/evaluations.mdx b/docs/development/evaluations.mdxdeleted file mode 100644index 917862c92..000000000--- a/docs/development/evaluations.mdx+++ /dev/null@@ -1,49 +0,0 @@-----title: "Evaluations"-description: "Test the Browser Use agent on standardized benchmarks"-icon: "chart-bar"-mode: "wide"------## Prerequisites--Browser Use uses proprietary/private test sets that must never be committed to Github and must be fetched through a authorized api request.-Accessing these test sets requires an approved Browser Use account.-There are currently no publicly available test sets, but some may be released in the future.--## Get an Api Access Key--First, navigate to https://browser-use.tools and log in with an authorized browser use account.--Then, click the "Account" button at the top right of the page, and click the "Cycle New Key" button on that page.--Copy the resulting url and secret key into your `.env` file. It should look like this:--```bash .env-EVALUATION_TOOL_URL= ...-EVALUATION_TOOL_SECRET_KEY= ...-```--## Running Evaluations--First, ensure your file `eval/service.py` is up to date.--Then run the file:--```bash-python eval/service.py-```--## Configuring Evaluations--You can modify the evaluation by providing flags to the evaluation script. For instance:--```bash-python eval/service.py --parallel_runs 5 --parallel_evaluations 5 --max-steps 25 --start 0 --end 100 --model gpt-4.1-mini-```--The evaluations webpage has a convenient GUI for generating these commands. To use it, navigate to https://browser-use.tools/dashboard.--Then click the button "New Eval Run" on the left panel. This will open a interface with selectors, inputs, sliders, and switches.--Input your desired configuration into the interface and copy the resulting python command at the bottom. Then run this command as before.diff --git a/docs/development/observability.mdx b/docs/development/observability.mdxindex dd1a12a45..edffde2c3 100644--- a/docs/development/observability.mdx+++ b/docs/development/observability.mdx@@ -10,20 +10,12 @@ mode: "wide"Browser Use has a native integration with [Laminar](https://lmnr.ai) - open-source platform for tracing, evals and labeling of AI agents.Read more about Laminar in the [Laminar docs](https://docs.lmnr.ai).-<Note>- Laminar excels at tracing browser agents by providing unified visibility into- both browser session recordings and agent execution steps.-</Note>-## Setup-To setup Laminar, you need to install the `lmnr` package and set the `LMNR_PROJECT_API_KEY` environment variable.--To get your project API key, you can either:-- Register on [Laminar Cloud](https://lmnr.ai) and get the key from your project settings-- Or spin up a local Laminar instance and get the key from the settings page+Register on [Laminar Cloud](https://lmnr.ai) and get the key from your project settings.+Set the `LMNR_PROJECT_API_KEY` environment variable.```bashpip install 'lmnr[all]'export LMNR_PROJECT_API_KEY=<your-project-api-key>@@ -34,21 +26,19 @@ export LMNR_PROJECT_API_KEY=<your-project-api-key>Then, you simply initialize the Laminar at the top of your project and both Browser Use and session recordings will be automatically traced.```python {5-8}-from browser_use.llm import ChatOpenAI-from browser_use import Agent+from browser_use import Agent, ChatOpenAIimport asynciofrom lmnr import Laminar, Instruments# this line auto-instruments Browser Use and any browser you use (local or remote)-Laminar.initialize(project_api_key="...", disable_batch=True, disabled_instruments={Instruments.BROWSER_USE}) # you can also pass project api key here+Laminar.initialize(project_api_key="...")async def main():agent = Agent(task="open google, search Laminar AI",llm=ChatOpenAI(model="gpt-4.1-mini"),)- result = await agent.run()- print(result)+ await agent.run()asyncio.run(main())```diff --git a/docs/docs.json b/docs/docs.jsonindex 40e926c37..e140b3835 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -56,13 +56,20 @@"pages": ["customize/browser-basic","customize/browser-real-browser",- "customize/browser-keep-open",- "customize/browser-multiple","customize/browser-remote","customize/browser-parameters"]},- "customize/sensitive-data",+ {+ "group": "Examples",+ "icon": "code",+ "pages": [+ "customize/fast-agent",+ "customize/sensitive-data",+ "customize/chain-agents",+ "customize/parallel-browser"+ ]+ },"customize/custom-functions"]},@@ -71,13 +78,17 @@"pages": ["development/contribution-guide","development/local-setup",- "customize/mcp-client",- "customize/mcp-server",+ {+ "group": "MCP",+ "icon": "link",+ "pages": [+ "customize/mcp-client",+ "customize/mcp-server"+ ]+ },"customize/hooks","development/telemetry",- "development/observability",- "development/evaluations",- "development/roadmap"+ "development/observability"]}]diff --git a/examples/simple.py b/examples/simple.pyindex 830f7e8e3..9776d9c6a 100644--- a/examples/simple.py+++ b/examples/simple.py@@ -1,3 +1,45 @@-from browser_use import Agent+import asyncio-Agent('Find the founders of browser-use').run_sync()+from browser_use import Agent, Browser, ChatOpenAI++# NOTE: This is still experimental, and agents might conflict each other.+++async def main():+ # Create 3 separate browser instances+ browsers = [+ Browser(+ user_data_dir=f'./temp-profile-{i}',+ headless=False,+ )+ for i in range(3)+ ]++ # Create 3 agents with different tasks+ agents = [+ Agent(+ task='Search for "browser automation" on Google',+ browser=browsers[0],+ llm=ChatOpenAI(model='gpt-4.1-mini'),+ ),+ Agent(+ task='Search for "AI agents" on DuckDuckGo',+ browser=browsers[1],+ llm=ChatOpenAI(model='gpt-4.1-mini'),+ ),+ Agent(+ task='Visit Wikipedia and search for "web scraping"',+ browser=browsers[2],+ llm=ChatOpenAI(model='gpt-4.1-mini'),+ ),+ ]++ # Run all agents in parallel+ tasks = [agent.run() for agent in agents]+ results = await asyncio.gather(*tasks, return_exceptions=True)++ print('🎉 All agents completed!')+++if __name__ == '__main__':+ asyncio.run(main())