Skip to content

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

Update simple example

Magnus Müller546dcc0387e8
diff --git a/docs/development/observability.mdx b/docs/development/observability.mdx
index 68dd8ecd4..2064533ee 100644
--- a/docs/development/observability.mdx
+++ b/docs/development/observability.mdx
@@ -37,14 +37,14 @@ from browser_use.llm import ChatOpenAI
from browser_use import Agent
import asyncio
-from lmnr import Laminar
+from lmnr import Laminar, Instruments
# this line auto-instruments Browser Use and any browser you use (local or remote)
-Laminar.initialize(project_api_key="...") # you can also pass project api key here
+Laminar.initialize(project_api_key="...", disable_batch=True, disabled_instruments={Instruments.BROWSER_USE}) # you can also pass project api key here
async def main():
agent = Agent(
task="open google, search Laminar AI",
- llm=ChatOpenAI(model="gpt-4o-mini"),
+ llm=ChatOpenAI(model="gpt-4.1-mini"),
)
result = await agent.run()
print(result)
diff --git a/examples/simple.py b/examples/simple.py
index 910fa596a..f9bfe8132 100644
--- a/examples/simple.py
+++ b/examples/simple.py
@@ -2,8 +2,6 @@ import asyncio
import os
import sys
-from lmnr import Instruments
-
from browser_use.llm.openai.chat import ChatOpenAI
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@@ -12,15 +10,6 @@ from dotenv import load_dotenv
load_dotenv()
-try:
- from lmnr import Laminar
-
- Laminar.initialize(
- project_api_key=os.getenv('LMNR_PROJECT_API_KEY'), disable_batch=True, disabled_instruments={Instruments.BROWSER_USE}
- )
-except Exception:
- print('Error initializing Laminar')
- pass
from browser_use import Agent
@@ -30,15 +19,12 @@ llm = ChatOpenAI(
)
-task = """Search for the translation of the word "love" from English to Spanish and list at least three contextual example sentences provided on Glosbe.
-Only use https://glosbe.com/ to achieve the task. Don't go to any other site. The task is achievable with just navigation from this site."""
+task = 'Find the founders of browser-use'
agent = Agent(task=task, llm=llm)
async def main():
- history = await agent.run()
- # token usage
- print(history.usage)
+ await agent.run()
if __name__ == '__main__':