Skip to content

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

Simple example

Magnus Müller330e4d9ab555
diff --git a/examples/simple.py b/examples/simple.py
index 3204f280e..f9bfe8132 100644
--- a/examples/simple.py
+++ b/examples/simple.py
@@ -10,39 +10,21 @@ from dotenv import load_dotenv
load_dotenv()
-try:
- from lmnr import Instruments, Laminar
-
- Laminar.initialize(project_api_key=os.getenv('LMNR_PROJECT_API_KEY'), disabled_instruments={Instruments.BROWSER_USE})
-except Exception:
- print('Error initializing Laminar')
- pass
from browser_use import Agent
# Initialize the model
llm = ChatOpenAI(
- model='o4-mini',
- temperature=0.2,
+ model='gpt-4.1-mini',
)
-# Optimized task with more specific instructions
-task = """
-Navigate to the Qatar Airways homepage and search for flights from Doha to Paris departing in the upcoming week; then list the available fare classes and prices.
-Only use https://www.qatarairways.com/ to achieve the task. Don't go to any other site. The task is achievable with just navigation from this site."""
-task = ' call done directly and repeat the word "New" 100 times'
-# Performance optimizations
-agent = Agent(
- task=task,
- llm=llm,
-)
+task = 'Find the founders of browser-use'
+agent = Agent(task=task, llm=llm)
async def main():
- history = await agent.run(max_steps=10)
- # token usage
- print(history.usage)
+ await agent.run()
if __name__ == '__main__':