repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/__init__.py
examples/__init__.py
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/demo_mode_example.py
examples/demo_mode_example.py
import asyncio from browser_use import Agent, ChatBrowserUse async def main() -> None: agent = Agent( task='Please find the latest commit on browser-use/browser-use repo and tell me the commit message. Please summarize what it is about.', llm=ChatBrowserUse(), demo_mode=True, ) await agent.run(max_steps=5) ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/apps/news-use/news_monitor.py
examples/apps/news-use/news_monitor.py
#!/usr/bin/env python3 """ News monitoring agent with browser-use + Gemini Flash. Automatically extracts and analyzes the latest articles from any news website. """ import argparse import asyncio import hashlib import json import logging import os import time from datetime import datetime from typing import Literal f...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/apps/ad-use/ad_generator.py
examples/apps/ad-use/ad_generator.py
import argparse import asyncio import logging import os import subprocess import sys from datetime import datetime from pathlib import Path from browser_use.utils import create_task_with_error_handling def setup_environment(debug: bool): if not debug: os.environ['BROWSER_USE_SETUP_LOGGING'] = 'false' os.environ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/apps/msg-use/login.py
examples/apps/msg-use/login.py
import asyncio import os from pathlib import Path from browser_use import Agent, BrowserSession from browser_use.llm.google import ChatGoogle GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY') # Browser profile directory for persistence (same as main script) USER_DATA_DIR = Path.home() / '.config' / 'whatsapp_scheduler' /...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/apps/msg-use/scheduler.py
examples/apps/msg-use/scheduler.py
#!/usr/bin/env python3 """ WhatsApp Message Scheduler - Send scheduled messages via WhatsApp Web """ import argparse import asyncio import json import logging import os import random import re from datetime import datetime, timedelta from pathlib import Path def setup_environment(debug: bool): if not debug: os.en...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/integrations/gmail_2fa_integration.py
examples/integrations/gmail_2fa_integration.py
""" Gmail 2FA Integration Example with Grant Mechanism This example demonstrates how to use the Gmail integration for handling 2FA codes during web automation with a robust credential grant and re-authentication system. Features: - Automatic credential validation and setup - Interactive OAuth grant flow when credentia...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/integrations/discord/discord_example.py
examples/integrations/discord/discord_example.py
""" This examples requires you to have a Discord bot token and the bot already added to a server. Five Steps to create and invite a Discord bot: 1. Create a Discord Application: * Go to the Discord Developer Portal: https://discord.com/developers/applications * Log in to the Discord website. * Click...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/integrations/discord/discord_api.py
examples/integrations/discord/discord_api.py
import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) from dotenv import load_dotenv load_dotenv() import discord # type: ignore from discord.ext import commands # type: ignore from browser_use.agent.service import Agent from browser_u...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/integrations/slack/slack_api.py
examples/integrations/slack/slack_api.py
import logging import os import sys from typing import Annotated sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_dotenv() from fastapi import Depends, FastAPI, HTTPException, Request from slack_sdk.errors import SlackApiError # type:...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/integrations/slack/slack_example.py
examples/integrations/slack/slack_example.py
import os import sys 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.browser import BrowserProfile from browser_use.llm import ChatGoogle from examples.integrations.slack.slack_api import SlackBot, app # lo...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/integrations/agentmail/2fa.py
examples/integrations/agentmail/2fa.py
import asyncio import os import sys from agentmail import AsyncAgentMail # type: ignore 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, Browser, ChatBrowserUse from examples.integrations.agentm...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/integrations/agentmail/email_tools.py
examples/integrations/agentmail/email_tools.py
""" Email management to enable 2fa. """ import asyncio import logging # run `pip install agentmail` to install the library from agentmail import AsyncAgentMail, Message, MessageReceivedEvent, Subscribe # type: ignore from agentmail.inboxes.types.inbox import Inbox # type: ignore from agentmail.inboxes.types.inbox_i...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/captcha.py
examples/use-cases/captcha.py
""" Goal: Automates CAPTCHA solving on a demo website. Simple try of the agent. @dev You need to add OPENAI_API_KEY to your environment variables. NOTE: captchas are hard. For this example it works. But e.g. for iframes it does not. for this example it helps to zoom in. """ import asyncio import os import sys sys.p...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/pcpartpicker.py
examples/use-cases/pcpartpicker.py
import asyncio from browser_use import Agent, Browser, ChatBrowserUse, Tools async def main(): browser = Browser(cdp_url='http://localhost:9222') llm = ChatBrowserUse() tools = Tools() task = """ Design me a mid-range water-cooled ITX computer Keep the total budget under $2000 Go to https://pcpar...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/phone_comparison.py
examples/use-cases/phone_comparison.py
import asyncio from pydantic import BaseModel, Field from browser_use import Agent, Browser, ChatBrowserUse class ProductListing(BaseModel): """A single product listing""" title: str = Field(..., description='Product title') url: str = Field(..., description='Full URL to listing') price: float = Field(..., des...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/check_appointment.py
examples/use-cases/check_appointment.py
# Goal: Checks for available visa appointment slots on the Greece MFA website. import asyncio import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_dotenv() from pydantic import BaseModel from browser_use import ChatO...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/shopping.py
examples/use-cases/shopping.py
import asyncio import os import sys 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, ChatOpenAI task = """ ### Prompt for Shopping Agent – Migros Online Grocery Order **Objective:** Visit [M...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/find_influencer_profiles.py
examples/use-cases/find_influencer_profiles.py
""" Show how to use custom outputs. @dev You need to add OPENAI_API_KEY to your environment variables. """ import asyncio import json import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_dotenv() import httpx from py...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/onepassword.py
examples/use-cases/onepassword.py
import os from onepassword.client import Client from browser_use import ActionResult, Agent, Browser, ChatOpenAI, Tools from browser_use.browser.session import BrowserSession """ Use Case: Securely log into a website using credentials stored in 1Password vault. - Use fill_field action to fill in username and passwor...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/apply_to_job.py
examples/use-cases/apply_to_job.py
import argparse import asyncio import json import os from dotenv import load_dotenv from browser_use import Agent, Browser, ChatOpenAI, Tools from browser_use.tools.views import UploadFileAction load_dotenv() async def apply_to_rochester_regional_health(info: dict, resume_path: str): """ json format: { "fi...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/buy_groceries.py
examples/use-cases/buy_groceries.py
import asyncio from pydantic import BaseModel, Field from browser_use import Agent, Browser, ChatBrowserUse class GroceryItem(BaseModel): """A single grocery item""" name: str = Field(..., description='Item name') price: float = Field(..., description='Price as number') brand: str | None = Field(None, descript...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/use-cases/extract_pdf_content.py
examples/use-cases/extract_pdf_content.py
#!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.11" # dependencies = ["browser-use", "mistralai"] # /// import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_dotenv() import asyncio import loggi...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/skills.py
examples/models/skills.py
import asyncio import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv from browser_use import Agent load_dotenv() async def run_search(): agent = Agent( # llm=llm, task='How many stars does the browser-use repo have?',...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/gpt-5-mini.py
examples/models/gpt-5-mini.py
""" Simple try of the agent. @dev You need to add OPENAI_API_KEY to your environment variables. """ import asyncio from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI load_dotenv() # All the models are type safe from OpenAI in case you need a list of supported models llm = ChatOpenAI(model='g...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/ollama.py
examples/models/ollama.py
# 1. Install Ollama: https://github.com/ollama/ollama # 2. Run `ollama serve` to start the server # 3. In a new terminal, install the model you want to use: `ollama pull llama3.1:8b` (this has 4.9GB) from browser_use import Agent, ChatOllama llm = ChatOllama(model='llama3.1:8b') Agent('find the founders of browser-...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/openrouter.py
examples/models/openrouter.py
""" Simple try of the agent. @dev You need to add OPENAI_API_KEY to your environment variables. """ import asyncio import os from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI load_dotenv() # All the models are type safe from OpenAI in case you need a list of supported models llm = ChatOpenA...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/aws.py
examples/models/aws.py
""" AWS Bedrock Examples This file demonstrates how to use AWS Bedrock models with browser-use. We provide two classes: 1. ChatAnthropicBedrock - Convenience class for Anthropic Claude models 2. ChatAWSBedrock - General AWS Bedrock client supporting all providers Requirements: - AWS credentials configured via environ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/qwen.py
examples/models/qwen.py
import os from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI load_dotenv() import asyncio # get an api key from https://modelstudio.console.alibabacloud.com/?tab=playground#/api-key api_key = os.getenv('ALIBABA_CLOUD') base_url = 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1' # so f...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/bu_oss.py
examples/models/bu_oss.py
""" Setup: 1. Get your API key from https://cloud.browser-use.com/new-api-key 2. Set environment variable: export BROWSER_USE_API_KEY="your-key" """ from dotenv import load_dotenv from browser_use import Agent, ChatBrowserUse load_dotenv() try: from lmnr import Laminar Laminar.initialize() except ImportError: p...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/llama4-groq.py
examples/models/llama4-groq.py
import asyncio import os import sys sys.path.append(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 ChatGroq groq_api_key = os.environ.get('GROQ_API_KEY') llm = ChatGroq( model='meta-llama/llama-4-...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/cerebras_example.py
examples/models/cerebras_example.py
""" Example of using Cerebras with browser-use. To use this example: 1. Set your CEREBRAS_API_KEY environment variable 2. Run this script Cerebras integration is working great for: - Direct text generation - Simple tasks without complex structured output - Fast inference for web automation Available Cerebras models ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/gpt-4.1.py
examples/models/gpt-4.1.py
""" Simple try of the agent. @dev You need to add OPENAI_API_KEY to your environment variables. """ import asyncio from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI load_dotenv() # All the models are type safe from OpenAI in case you need a list of supported models llm = ChatOpenAI(model='g...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/moonshot.py
examples/models/moonshot.py
import asyncio import os from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI load_dotenv() # Get API key from environment variable api_key = os.getenv('MOONSHOT_API_KEY') if api_key is None: print('Make sure you have MOONSHOT_API_KEY set in your .env file') print('Get your API key from https:...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/claude-4-sonnet.py
examples/models/claude-4-sonnet.py
""" Simple script that runs the task of opening amazon and searching. @dev Ensure we have a `ANTHROPIC_API_KEY` variable in our `.env` file. """ import asyncio import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_doten...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/vercel_ai_gateway.py
examples/models/vercel_ai_gateway.py
""" Example using Vercel AI Gateway with browser-use. Vercel AI Gateway provides an OpenAI-compatible API endpoint that can proxy requests to various AI providers. This allows you to use Vercel's infrastructure for rate limiting, caching, and monitoring. Prerequisites: 1. Set VERCEL_API_KEY in your environment variab...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/oci_models.py
examples/models/oci_models.py
""" Oracle Cloud Infrastructure (OCI) Raw API Example This example demonstrates how to use OCI's Generative AI service with browser-use using the raw API integration (ChatOCIRaw) without Langchain dependencies. @dev You need to: 1. Set up OCI configuration file at ~/.oci/config 2. Have access to OCI Generative AI mod...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/gemini-3.py
examples/models/gemini-3.py
import asyncio import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv from browser_use import Agent, ChatGoogle load_dotenv() api_key = os.getenv('GOOGLE_API_KEY') if not api_key: raise ValueError('GOOGLE_API_KEY is not set...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/browser_use_llm.py
examples/models/browser_use_llm.py
""" Example of the fastest + smartest LLM for browser automation. Setup: 1. Get your API key from https://cloud.browser-use.com/new-api-key 2. Set environment variable: export BROWSER_USE_API_KEY="your-key" """ import asyncio import os from dotenv import load_dotenv from browser_use import Agent, ChatBrowserUse lo...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/novita.py
examples/models/novita.py
""" Simple try of the agent. @dev You need to add NOVITA_API_KEY to your environment variables. """ import asyncio import os import sys 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, ChatOpe...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/azure_openai.py
examples/models/azure_openai.py
""" Simple try of the agent with Azure OpenAI. @dev You need to add AZURE_OPENAI_KEY and AZURE_OPENAI_ENDPOINT to your environment variables. For GPT-5.1 Codex models (gpt-5.1-codex-mini, etc.), use: llm = ChatAzureOpenAI( model='gpt-5.1-codex-mini', api_version='2025-03-01-preview', # Required f...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/mistral.py
examples/models/mistral.py
""" Simple agent run with Mistral. You need to set MISTRAL_API_KEY in your environment (and optionally MISTRAL_BASE_URL). """ import asyncio from dotenv import load_dotenv from browser_use import Agent from browser_use.llm.mistral import ChatMistral load_dotenv() llm = ChatMistral(model='mistral-small-2506', temp...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/lazy_import.py
examples/models/lazy_import.py
from browser_use import Agent, models # available providers for this import style: openai, azure, google agent = Agent(task='Find founders of browser-use', llm=models.azure_gpt_4_1_mini) agent.run_sync()
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/deepseek-chat.py
examples/models/deepseek-chat.py
import asyncio import os from browser_use import Agent from browser_use.llm import ChatDeepSeek # Add your custom instructions extend_system_message = """ Remember the most important rules: 1. When performing a search task, open https://www.google.com/ first for search. 2. Final output. """ deepseek_api_key = os.ge...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/modelscope_example.py
examples/models/modelscope_example.py
""" Simple try of the agent. @dev You need to add MODELSCOPE_API_KEY to your environment variables. """ import asyncio import os from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI # dotenv load_dotenv() api_key = os.getenv('MODELSCOPE_API_KEY', '') if not api_key: raise ValueError('MODELSCO...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/gemini.py
examples/models/gemini.py
import asyncio import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv from browser_use import Agent, ChatGoogle load_dotenv() api_key = os.getenv('GOOGLE_API_KEY') if not api_key: raise ValueError('GOOGLE_API_KEY is not set...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/langchain/serializer.py
examples/models/langchain/serializer.py
import json from typing import overload from langchain_core.messages import ( # pyright: ignore AIMessage, HumanMessage, SystemMessage, ) from langchain_core.messages import ( # pyright: ignore ToolCall as LangChainToolCall, ) from langchain_core.messages.base import BaseMessage as LangChainBaseMessage # pyrigh...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/langchain/chat.py
examples/models/langchain/chat.py
from dataclasses import dataclass from typing import TYPE_CHECKING, TypeVar, overload from pydantic import BaseModel from browser_use.llm.base import BaseChatModel from browser_use.llm.exceptions import ModelProviderError from browser_use.llm.messages import BaseMessage from browser_use.llm.views import ChatInvokeCom...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/langchain/example.py
examples/models/langchain/example.py
""" Example of using LangChain models with browser-use. This example demonstrates how to: 1. Wrap a LangChain model with ChatLangchain 2. Use it with a browser-use Agent 3. Run a simple web automation task @file purpose: Example usage of LangChain integration with browser-use """ import asyncio from langchain_opena...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/models/langchain/__init__.py
examples/models/langchain/__init__.py
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/observability/openLLMetry.py
examples/observability/openLLMetry.py
import asyncio import os from dotenv import load_dotenv # test if traceloop is installed try: from traceloop.sdk import Traceloop # type: ignore except ImportError: print('Traceloop is not installed') exit(1) from browser_use import Agent load_dotenv() api_key = os.getenv('TRACELOOP_API_KEY') Traceloop.init(api...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/small_model_for_extraction.py
examples/features/small_model_for_extraction.py
import asyncio import os import sys 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, ChatOpenAI # This uses a bigger model for the planning # And a smaller model for the page content extraction ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/process_agent_output.py
examples/features/process_agent_output.py
import asyncio import os import sys from pprint import pprint 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, ChatOpenAI from browser_use.agent.views import AgentHistoryList from browser_use.bro...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/stop_externally.py
examples/features/stop_externally.py
import asyncio import os import random import sys from browser_use.llm.google.chat import ChatGoogle sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from dotenv import load_dotenv load_dotenv() from browser_use import Agent llm = ChatGoogle(model='gemini-flash-latest', temperature=1.0...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/custom_output.py
examples/features/custom_output.py
""" Show how to use custom outputs. @dev You need to add OPENAI_API_KEY to your environment variables. """ import asyncio import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_dotenv() from pydantic import BaseModel ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/blocked_domains.py
examples/features/blocked_domains.py
import asyncio import os import sys 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, ChatOpenAI from browser_use.browser import BrowserProfile, BrowserSession llm = ChatOpenAI(model='gpt-4o-mini...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/multi_tab.py
examples/features/multi_tab.py
""" Simple try of the agent. @dev You need to add OPENAI_API_KEY to your environment variables. """ import asyncio import os import sys 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, ChatOpen...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/scrolling_page.py
examples/features/scrolling_page.py
# Goal: Automates webpage scrolling with various scrolling actions, including element-specific scrolling. import asyncio import os import sys 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, Cha...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/add_image_context.py
examples/features/add_image_context.py
""" Show how to use sample_images to add image context for your task """ import asyncio import base64 from pathlib import Path from typing import Any from dotenv import load_dotenv from browser_use import Agent from browser_use.llm import ChatOpenAI from browser_use.llm.messages import ContentPartImageParam, Content...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/rerun_history.py
examples/features/rerun_history.py
""" Example: Rerunning saved agent history with variable detection and substitution This example shows how to: 1. Run an agent and save its history (including initial URL navigation) 2. Detect variables in the saved history (emails, names, dates, etc.) 3. Rerun the history with substituted values (different data) 4. G...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/parallel_agents.py
examples/features/parallel_agents.py
import asyncio import os import sys from pathlib import Path 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 ChatOpenAI from browser_use.agent.service import Agent from browser_use.browser import Brows...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/sensitive_data.py
examples/features/sensitive_data.py
import asyncio import os import sys 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, ChatOpenAI # Initialize the model llm = ChatOpenAI( model='gpt-4.1', temperature=0.0, ) # Simple case: the ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/judge_trace.py
examples/features/judge_trace.py
""" Setup: 1. Get your API key from https://cloud.browser-use.com/new-api-key 2. Set environment variable: export BROWSER_USE_API_KEY="your-key" """ import asyncio import os 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(o...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/secure.py
examples/features/secure.py
""" Azure OpenAI example with data privacy and high-scale configuration. Environment Variables Required: - AZURE_OPENAI_KEY (or AZURE_OPENAI_API_KEY) - AZURE_OPENAI_ENDPOINT - AZURE_OPENAI_DEPLOYMENT (optional) DATA PRIVACY WITH AZURE OPENAI: ✅ Good News: No Training on Your Data by Default Azure OpenAI Service alre...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/download_file.py
examples/features/download_file.py
import asyncio import os import sys 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, Browser, ChatGoogle api_key = os.getenv('GOOGLE_API_KEY') if not api_key: raise ValueError('GOOGLE_API_KEY ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/initial_actions.py
examples/features/initial_actions.py
import asyncio import os import sys 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, ChatOpenAI llm = ChatOpenAI(model='gpt-4.1-mini') initial_actions = [ {'navigate': {'url': 'https://www.goo...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/video_recording.py
examples/features/video_recording.py
import asyncio from pathlib import Path from browser_use import Agent, Browser, ChatOpenAI # NOTE: To use this example, install imageio[ffmpeg], e.g. with uv pip install "browser-use[video]" async def main(): browser_session = Browser(record_video_dir=Path('./tmp/recordings')) agent = Agent( task='Go to github...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/custom_system_prompt.py
examples/features/custom_system_prompt.py
import asyncio import json import os import sys 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, ChatOpenAI extend_system_message = ( 'REMEMBER the most important RULE: ALWAYS open first a new...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/follow_up_tasks.py
examples/features/follow_up_tasks.py
import asyncio import os import sys from browser_use.browser.profile import BrowserProfile 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 profile = BrowserProfile(keep_alive=True) task = """...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/fallback_model.py
examples/features/fallback_model.py
""" Example: Using a fallback LLM model. When the primary LLM fails with rate limits (429), authentication errors (401), payment/credit errors (402), or server errors (500, 502, 503, 504), the agent automatically switches to the fallback model and continues execution. Note: The primary LLM will first exhaust its own ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/restrict_urls.py
examples/features/restrict_urls.py
import asyncio import os import sys 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, ChatOpenAI from browser_use.browser import BrowserProfile, BrowserSession llm = ChatOpenAI(model='gpt-4.1-min...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/follow_up_task.py
examples/features/follow_up_task.py
from dotenv import load_dotenv from browser_use import Agent, Browser load_dotenv() import asyncio async def main(): browser = Browser(keep_alive=True) await browser.start() agent = Agent(task='search for browser-use.', browser_session=browser) await agent.run(max_steps=2) agent.add_new_task('return the tit...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/features/large_blocklist.py
examples/features/large_blocklist.py
""" Example: Using large blocklists (400k+ domains) with automatic optimization This example demonstrates: 1. Loading a real-world blocklist (HaGeZi's Pro++ with 439k+ domains) 2. Automatic conversion to set for O(1) lookup performance 3. Testing that blocked domains are actually blocked Performance: ~0.02ms per doma...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/file_system/file_system.py
examples/file_system/file_system.py
import asyncio import os import pathlib import shutil from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI load_dotenv() SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) agent_dir = SCRIPT_DIR / 'file_system' agent_dir.mkdir(exist_ok=True) conversation_dir = agent_dir / 'co...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/file_system/alphabet_earnings.py
examples/file_system/alphabet_earnings.py
import asyncio import os import pathlib import shutil from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI load_dotenv() SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) agent_dir = SCRIPT_DIR / 'alphabet_earnings' agent_dir.mkdir(exist_ok=True) task = """ Go to https://abc...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/file_system/excel_sheet.py
examples/file_system/excel_sheet.py
import asyncio import os import sys from browser_use.llm.openai.chat import ChatOpenAI sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from dotenv import load_dotenv load_dotenv() from browser_use import Agent llm = ChatOpenAI(model='o4-mini') task = ( 'Find current stock price of ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/code_agent/extract_products.py
examples/code_agent/extract_products.py
""" Example: Using code-use mode to extract products from multiple pages. This example demonstrates the new code-use mode, which works like a Jupyter notebook where the LLM writes Python code that gets executed in a persistent namespace. The agent can: - Navigate to pages - Extract data using JavaScript - Combine res...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/code_agent/filter_webvoyager_dataset.py
examples/code_agent/filter_webvoyager_dataset.py
import asyncio from browser_use.code_use import CodeAgent async def main(): task = """ Find the WebVoyager dataset, download it and create a new version where you remove all tasks which have older dates than today. """ # Create code-use agent agent = CodeAgent( task=task, max_steps=25, ) try: # Run the ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/sandbox/example.py
examples/sandbox/example.py
"""Example of using sandbox execution with Browser-Use Agent This example demonstrates how to use the @sandbox decorator to run browser automation tasks with the Agent in a sandbox environment. To run this example: 1. Set your BROWSER_USE_API_KEY environment variable 2. Set your LLM API key (OPENAI_API_KEY, ANTHROPIC...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/sandbox/structured_output.py
examples/sandbox/structured_output.py
"""Example of using structured output with sandbox execution To run: export BROWSER_USE_API_KEY=your_key python examples/sandbox/structured_output.py """ import asyncio import os from pydantic import BaseModel, Field from browser_use import Agent, Browser, ChatBrowserUse, sandbox from browser_use.agent.view...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/cloud/02_fast_mode_gemini.py
examples/cloud/02_fast_mode_gemini.py
""" Cloud Example 2: Ultra-Fast Mode with Gemini Flash ⚡ ==================================================== This example demonstrates the fastest and most cost-effective configuration: - Gemini 2.5 Flash model ($0.01 per step) - No proxy (faster execution, but no captcha solving) - No element highlighting (better pe...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/cloud/04_proxy_usage.py
examples/cloud/04_proxy_usage.py
""" Cloud Example 4: Proxy Usage 🌍 =============================== This example demonstrates reliable proxy usage scenarios: - Different country proxies for geo-restrictions - IP address and location verification - Region-specific content access (streaming, news) - Search result localization by country - Mobile/resid...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/cloud/05_search_api.py
examples/cloud/05_search_api.py
""" Cloud Example 5: Search API (Beta) 🔍 ===================================== This example demonstrates the Browser Use Search API (BETA): - Simple search: Search Google and extract from multiple results - URL search: Extract specific content from a target URL - Deep navigation through websites (depth parameter) - R...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/cloud/01_basic_task.py
examples/cloud/01_basic_task.py
""" Cloud Example 1: Your First Browser Use Cloud Task ================================================== This example demonstrates the most basic Browser Use Cloud functionality: - Create a simple automation task - Get the task ID - Monitor completion - Retrieve results Perfect for first-time cloud users to understa...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/cloud/03_structured_output.py
examples/cloud/03_structured_output.py
""" Cloud Example 3: Structured JSON Output 📋 ========================================== This example demonstrates how to get structured, validated JSON output: - Define Pydantic schemas for type safety - Extract structured data from websites - Validate and parse JSON responses - Handle different data types and neste...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/browser/playwright_integration.py
examples/browser/playwright_integration.py
""" Key features: 1. Browser-Use and Playwright sharing the same Chrome instance via CDP 2. Take actions with Playwright and continue with Browser-Use actions 3. Let the agent call Playwright functions like screenshot or click on selectors """ import asyncio import os import subprocess import sys import tempfile from...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/browser/parallel_browser.py
examples/browser/parallel_browser.py
import asyncio from browser_use import Agent, Browser, ChatOpenAI # NOTE: This is still experimental, and agents might conflict each other. async def main(): # Create 3 separate browser instances browsers = [ Browser( user_data_dir=f'./temp-profile-{i}', headless=False, ) for i in range(3) ] # Crea...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/browser/using_cdp.py
examples/browser/using_cdp.py
""" Simple demonstration of the CDP feature. To test this locally, follow these steps: 1. Find the chrome executable file. 2. On mac by default, the chrome is in `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` 3. Add the following argument to the shortcut: `--remote-debugging-port=9222` 4. Open a web...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/browser/save_cookies.py
examples/browser/save_cookies.py
import asyncio import os import sys 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 Browser # Connect to your existing Chrome browser browser = Browser( executable_path='/Applications/Google Chrome.a...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/browser/cloud_browser.py
examples/browser/cloud_browser.py
""" Examples of using Browser-Use cloud browser service. Prerequisites: 1. Set BROWSER_USE_API_KEY environment variable 2. Active subscription at https://cloud.browser-use.com """ import asyncio from dotenv import load_dotenv from browser_use import Agent, Browser, ChatBrowserUse load_dotenv() async def basic():...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/browser/real_browser.py
examples/browser/real_browser.py
import asyncio import os import sys 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, Browser, ChatGoogle # Connect to your existing Chrome browser browser = Browser( executable_path='/Applicati...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/ui/streamlit_demo.py
examples/ui/streamlit_demo.py
""" To use it, you'll need to install streamlit, and run with: python -m streamlit run streamlit_demo.py """ import asyncio import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_dotenv() import streamlit as st # typ...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/ui/command_line.py
examples/ui/command_line.py
""" To Use It: Example 1: Using OpenAI (default), with default task: 'go to reddit and search for posts about browser-use' python command_line.py Example 2: Using OpenAI with a Custom Query python command_line.py --query "go to google and search for browser-use" Example 3: Using Anthropic's Claude Model with a Custo...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/ui/gradio_demo.py
examples/ui/gradio_demo.py
# pyright: reportMissingImports=false import asyncio import os import sys from dataclasses import dataclass sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_dotenv() # Third-party imports import gradio as gr # type: ignore from rich.c...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/getting_started/01_basic_search.py
examples/getting_started/01_basic_search.py
""" Setup: 1. Get your API key from https://cloud.browser-use.com/new-api-key 2. Set environment variable: export BROWSER_USE_API_KEY="your-key" """ import asyncio import os 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(o...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/getting_started/04_multi_step_task.py
examples/getting_started/04_multi_step_task.py
""" Getting Started Example 4: Multi-Step Task This example demonstrates how to: - Perform a complex workflow with multiple steps - Navigate between different pages - Combine search, form filling, and data extraction - Handle a realistic end-to-end scenario This is the most advanced getting started example, combining...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/getting_started/02_form_filling.py
examples/getting_started/02_form_filling.py
""" Getting Started Example 2: Form Filling This example demonstrates how to: - Navigate to a website with forms - Fill out input fields - Submit forms - Handle basic form interactions This builds on the basic search example by showing more complex interactions. Setup: 1. Get your API key from https://cloud.browser-...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/getting_started/05_fast_agent.py
examples/getting_started/05_fast_agent.py
import asyncio import os 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, BrowserProfile # Speed optimization inst...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/getting_started/03_data_extraction.py
examples/getting_started/03_data_extraction.py
""" Getting Started Example 3: Data Extraction This example demonstrates how to: - Navigate to a website with structured data - Extract specific information from the page - Process and organize the extracted data - Return structured results This builds on previous examples by showing how to get valuable data from web...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false
browser-use/browser-use
https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/examples/custom-functions/onepassword_2fa.py
examples/custom-functions/onepassword_2fa.py
import asyncio import logging import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from dotenv import load_dotenv load_dotenv() from onepassword.client import Client # type: ignore # pip install onepassword-sdk from browser_use import ActionResult, Ag...
python
MIT
630f85dd05127c9d42810a5db235a14f5bac9043
2026-01-04T14:38:16.467592Z
false