Installation & Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The browser-use library provides a streamlined interface for connecting AI agents to web browsers. It leverages Playwright for browser automation and integrates with various Large Language Model (LLM) providers through LangChain. The installation process focuses on setting up the Python environment, installing browser binaries, and configuring environment variables for API access.
Configuration is handled primarily through data classes like BrowserContextConfig, which allow developers to fine-tune browser behavior, security settings, and interaction parameters. The system is designed to be extensible, supporting integrations with platforms like Slack and Discord, as well as providing multiple user interface options for testing and deployment.
Sources: README.md:1-30, browser_use/browser/context.py:48-115
Core Installation Steps
Environment Prerequisites
The project requires Python version 3.11 or higher. Dependencies are managed via standard Python package managers like pip.
# Install the core library
pip install browser-use
# Install necessary browser binaries via Playwright
playwright install
Sources: pyproject.toml:9-10, README.md:38-46
Dependency Management
The library relies on several key packages for its functionality, including playwright for automation, langchain for LLM orchestration, and pydantic for data validation.
| Package | Minimum Version | Purpose |
|---|---|---|
playwright | >=1.49.0 | Browser automation engine |
langchain | ==0.3.14 | AI agent framework |
pydantic | >=2.10.4 | Data modeling and validation |
beautifulsoup4 | >=4.12.3 | DOM parsing |
python-dotenv | >=1.0.1 | Environment variable management |
Sources: pyproject.toml:15-33
Configuration Management
Browser Context Configuration
The BrowserContextConfig class defines the operational parameters for browser sessions. This includes network timeouts, window dimensions, and security overrides.
The diagram shows the logical grouping of configuration options within the BrowserContextConfig class.
| Option | Type | Default | Description |
|---|---|---|---|
cookies_file | str | None | None | Path for persistent cookie storage |
disable_security | bool | False | Disables CSP and HTTPS error checks |
browser_window_size | TypedDict | 1280x1100 | Default width and height |
viewport_expansion | int | 500 | Pixels beyond viewport to include in LLM state |
highlight_elements | bool | True | Visually marks elements in the browser |
Sources: browser_use/browser/context.py:48-115
Environment Variables
API keys and sensitive credentials must be configured in a .env file at the project root.
# Primary LLM Provider
OPENAI_API_KEY=your_key_here
# Optional Integrations
SLACK_BOT_TOKEN=xoxb-your-token
SLACK_SIGNING_SECRET=your-secret
DISCORD_BOT_TOKEN=your-discord-token
Sources: README.md:65-68, examples/integrations/slack/README.md:38-51, examples/integrations/discord/discord_example.py:53-55
Integration & UI Setup
Integration Workflows
Setting up integrations (e.g., Slack) requires configuring external webhooks and event subscriptions.
The sequence diagram illustrates the flow of events when configuring a local development environment for third-party integrations using a tunneling service.
Sources: examples/integrations/slack/README.md:15-30
User Interface Options
The repository includes several demo interfaces for interacting with the agent without writing custom code.
| UI Script | Framework | Description |
|---|---|---|
command_line.py | Terminal | CLI argument parsing |
gradio_demo.py | Gradio | Web-based interactive UI |
streamlit_demo.py | Streamlit | Data-focused web interface |
Sources: examples/ui/README.md:1-12
Summary
Installation of browser-use requires Python 3.11+, the library package, and Playwright browser binaries. Configuration is centralized in BrowserContextConfig for browser behavior and .env files for security credentials. The system supports various deployment modes, from simple CLI scripts to complex integrations with Slack and Discord, each requiring specific environmental and platform-side configurations.