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
Refactor: Use ChatBrowserUse LLM and BrowserUse API key
Cursor Agent7fd7f7329e65
diff --git a/README.md b/README.mdindex 42f989749..d51cabe4c 100644--- a/README.md+++ b/README.md@@ -45,23 +45,21 @@ Download chromium using playwright's shortcut:uvx playwright install chromium --with-deps --no-shell```-Create a `.env` file and add your API key. Don't have one? Start with a [free Gemini key](https://aistudio.google.com/app/u/1/apikey?pli=1).+Get your API key from [Browser Use Cloud](https://cloud.browser-use.com/dashboard/api) and add it to your `.env` file:```bash-GEMINI_API_KEY=+BROWSER_USE_API_KEY=your-key```Run your first agent:```python-from browser_use import Agent, ChatGoogle-from dotenv import load_dotenv-load_dotenv()+from browser_use import Agent+from browser_use.llm import ChatBrowserUseagent = Agent(- task="Find the number of stars of the browser-use repo",- llm=ChatGoogle(model="gemini-flash-latest"),- # browser=Browser(use_cloud=True), # Uses Browser-Use cloud for the browser+ task='Find the number of stars of the following repos: browser-use, playwright, stagehand, react, nextjs',+ llm=ChatBrowserUse(),)agent.run_sync()```@@ -76,7 +74,8 @@ Want to bypass Cloudflare, or any other anti-bot protection?Simply go to [Browser Use Cloud](https://docs.cloud.browser-use.com) grab a `BROWSER_USE_API_KEY` and use the `use_cloud` parameter.```python-from browser_use import Agent, Browser, ChatOpenAI+from browser_use import Agent, Browser+from browser_use.llm import ChatBrowserUse# Use Browser-Use cloud browser servicebrowser = Browser(@@ -85,7 +84,7 @@ browser = Browser(agent = Agent(task="Your task here",- llm=ChatOpenAI(model='gpt-4.1-mini'),+ llm=ChatBrowserUse(),browser=browser,)```diff --git a/examples/getting_started/01_basic_search.py b/examples/getting_started/01_basic_search.pyindex 74f874ba2..df2df800d 100644--- a/examples/getting_started/01_basic_search.py+++ b/examples/getting_started/01_basic_search.py@@ -1,3 +1,9 @@+"""+Setup:+1. Get your API key from https://cloud.browser-use.com/dashboard/api+2. Set environment variable: export BROWSER_USE_API_KEY="your-key"+"""+import asyncioimport osimport sys@@ -5,15 +11,12 @@ import sys# Add the parent directory to the path so we can import browser_usesys.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, ChatOpenAI+from browser_use import Agent+from browser_use.llm import ChatBrowserUseasync def main():- llm = ChatOpenAI(model='gpt-4.1-mini')+ llm = ChatBrowserUse()task = "Search Google for 'what is browser automation' and tell me the top 3 results"agent = Agent(task=task, llm=llm)await agent.run()diff --git a/examples/getting_started/02_form_filling.py b/examples/getting_started/02_form_filling.pyindex d0a96a746..d6233adb1 100644--- a/examples/getting_started/02_form_filling.py+++ b/examples/getting_started/02_form_filling.py@@ -8,6 +8,10 @@ This example demonstrates how to:- Handle basic form interactionsThis builds on the basic search example by showing more complex interactions.++Setup:+1. Get your API key from https://cloud.browser-use.com/dashboard/api+2. Set environment variable: export BROWSER_USE_API_KEY="your-key""""import asyncio@@ -17,16 +21,13 @@ import sys# Add the parent directory to the path so we can import browser_usesys.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, ChatOpenAI+from browser_use import Agent+from browser_use.llm import ChatBrowserUseasync def main():# Initialize the model- llm = ChatOpenAI(model='gpt-4.1-mini')+ llm = ChatBrowserUse()# Define a form filling tasktask = """diff --git a/examples/getting_started/03_data_extraction.py b/examples/getting_started/03_data_extraction.pyindex 8f44a089a..e4c0cf62d 100644--- a/examples/getting_started/03_data_extraction.py+++ b/examples/getting_started/03_data_extraction.py@@ -8,6 +8,10 @@ This example demonstrates how to:- Return structured resultsThis builds on previous examples by showing how to get valuable data from websites.++Setup:+1. Get your API key from https://cloud.browser-use.com/dashboard/api+2. Set environment variable: export BROWSER_USE_API_KEY="your-key""""import asyncio@@ -17,16 +21,13 @@ import sys# Add the parent directory to the path so we can import browser_usesys.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, ChatOpenAI+from browser_use import Agent+from browser_use.llm import ChatBrowserUseasync def main():# Initialize the model- llm = ChatOpenAI(model='gpt-4.1-mini')+ llm = ChatBrowserUse()# Define a data extraction tasktask = """diff --git a/examples/getting_started/04_multi_step_task.py b/examples/getting_started/04_multi_step_task.pyindex bf9cd6a53..bbee26c7b 100644--- a/examples/getting_started/04_multi_step_task.py+++ b/examples/getting_started/04_multi_step_task.py@@ -8,6 +8,10 @@ This example demonstrates how to:- Handle a realistic end-to-end scenarioThis is the most advanced getting started example, combining all previous concepts.++Setup:+1. Get your API key from https://cloud.browser-use.com/dashboard/api+2. Set environment variable: export BROWSER_USE_API_KEY="your-key""""import asyncio@@ -17,16 +21,13 @@ import sys# Add the parent directory to the path so we can import browser_usesys.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, ChatOpenAI+from browser_use import Agent+from browser_use.llm import ChatBrowserUseasync def main():# Initialize the model- llm = ChatOpenAI(model='gpt-4.1-mini')+ llm = ChatBrowserUse()# Define a multi-step tasktask = """diff --git a/examples/simple.py b/examples/simple.pyindex 4b4403047..1663f6a92 100644--- a/examples/simple.py+++ b/examples/simple.py@@ -1,12 +1,14 @@-from dotenv import load_dotenv+"""+Setup:+1. Get your API key from https://cloud.browser-use.com/dashboard/api+2. Set environment variable: export BROWSER_USE_API_KEY="your-key"+"""-from browser_use import Agent, ChatGoogle--load_dotenv()+from browser_use import Agent+from browser_use.llm import ChatBrowserUseagent = Agent(- task='Find the number of stars of the browser-use repo',- llm=ChatGoogle(model='gemini-flash-latest'),- # browser=Browser(use_cloud=True), # Uses Browser-Use cloud for the browser+ task='Find the number of stars of the following repos: browser-use, playwright, stagehand, react, nextjs',+ llm=ChatBrowserUse(),)agent.run_sync()