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
gemini example
Magnus Müllerf7c16976cb7f
diff --git a/examples/models/gemini.py b/examples/models/gemini.pyindex 4ffdc0224..0b12f2ad7 100644--- a/examples/models/gemini.py+++ b/examples/models/gemini.py@@ -5,7 +5,9 @@ from dotenv import load_dotenvfrom langchain_google_genai import ChatGoogleGenerativeAIfrom pydantic import SecretStr-from browser_use import Agent+from browser_use import Agent, BrowserConfig+from browser_use.browser.browser import Browser+from browser_use.browser.context import BrowserContextConfigload_dotenv()api_key = os.getenv('GEMINI_API_KEY')@@ -14,14 +16,21 @@ if not api_key:llm = ChatGoogleGenerativeAI(model='gemini-2.0-flash-exp', api_key=SecretStr(api_key))+browser = Browser(+ config=BrowserConfig(+ new_context_config=BrowserContextConfig(+ viewport_expansion=0,+ )+ )+)+async def run_search():agent = Agent(- task=(- 'Go to url r/LocalLLaMA subreddit and search for "browser use" in the search bar and click on the first post and find the funniest comment'- ),+ task='Go to amazon.com, search for laptop, sort by best rating, and give me the price of the first result',llm=llm,max_actions_per_step=4,+ browser=browser,)await agent.run(max_steps=25)