Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Refactor: Load environment variables and update example tasks

Cursor Agent66f6ecb2a868
diff --git a/.env.example b/.env.example
index d57d2c24e..b148217d0 100644
--- a/.env.example
+++ b/.env.example
@@ -19,9 +19,9 @@ CDP_LOGGING_LEVEL=WARNING
# Enable/disable anonymous telemetry
ANONYMIZED_TELEMETRY=true
-# Browser Use Cloud Configuration (optional)
-# Your Browser Use Cloud API key - get it from: https://cloud.browser-use.com/dashboard/api
-# BROWSER_USE_API_KEY=your_api_key_here
+# Browser Use Cloud Configuration
+# Get your API key from: https://cloud.browser-use.com/dashboard/api
+BROWSER_USE_API_KEY=your_api_key_here
# Custom API base URL (for enterprise installations)
# BROWSER_USE_CLOUD_API_URL=https://api.browser-use.com
@@ -29,7 +29,7 @@ ANONYMIZED_TELEMETRY=true
# Cloud sync settings
# BROWSER_USE_CLOUD_SYNC=false
-# Model Configuration
+# Model Configuration (optional - use if you want to use other LLM providers)
# Default LLM model to use
# OPENAI_API_KEY=your_openai_api_key_here
# ANTHROPIC_API_KEY=your_anthropic_api_key_here
@@ -55,10 +55,3 @@ ANONYMIZED_TELEMETRY=true
# BROWSER_USE_NO_PROXY=localhost,127.0.0.1,*.internal
# BROWSER_USE_PROXY_USERNAME=username
# BROWSER_USE_PROXY_PASSWORD=password
-
-
-# Browser use LLM
-
-
-# Your Browser Use Cloud API key - get it from: https://cloud.browser-use.com/dashboard/api
-# BROWSER_USE_API_KEY=your_api_key_here
diff --git a/examples/getting_started/01_basic_search.py b/examples/getting_started/01_basic_search.py
index df2df800d..aca081fa1 100644
--- a/examples/getting_started/01_basic_search.py
+++ b/examples/getting_started/01_basic_search.py
@@ -11,6 +11,10 @@ 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
from browser_use.llm import ChatBrowserUse
diff --git a/examples/getting_started/02_form_filling.py b/examples/getting_started/02_form_filling.py
index d6233adb1..521270806 100644
--- a/examples/getting_started/02_form_filling.py
+++ b/examples/getting_started/02_form_filling.py
@@ -21,6 +21,10 @@ 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
from browser_use.llm import ChatBrowserUse
diff --git a/examples/getting_started/03_data_extraction.py b/examples/getting_started/03_data_extraction.py
index e4c0cf62d..a54251d5c 100644
--- a/examples/getting_started/03_data_extraction.py
+++ b/examples/getting_started/03_data_extraction.py
@@ -21,6 +21,10 @@ 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
from browser_use.llm import ChatBrowserUse
diff --git a/examples/getting_started/04_multi_step_task.py b/examples/getting_started/04_multi_step_task.py
index bbee26c7b..6c36e9ad6 100644
--- a/examples/getting_started/04_multi_step_task.py
+++ b/examples/getting_started/04_multi_step_task.py
@@ -21,6 +21,10 @@ 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
from browser_use.llm import ChatBrowserUse
diff --git a/examples/simple.py b/examples/simple.py
index 9f2475c86..524e88dce 100644
--- a/examples/simple.py
+++ b/examples/simple.py
@@ -4,11 +4,15 @@ Setup:
2. Set environment variable: export BROWSER_USE_API_KEY="your-key"
"""
+from dotenv import load_dotenv
+
from browser_use import Agent
from browser_use.llm import ChatBrowserUse
+load_dotenv()
+
agent = Agent(
- task='Find the number of stars of the browser-use repo',
+ task='Find the number of stars of the following repos: browser-use, playwright, stagehand, react, nextjs',
llm=ChatBrowserUse(),
)
agent.run_sync()