Skip to main content
If you’re building agentic workflows with Agno Agents that need to interact with websites, fill out forms, or replicate user’s actions, use Browserbase. It can manage that infrastructure so you don’t have to maintain your own fleet of headless browsers.

Prerequisites

Set these environment variables required by BrowserbaseTools to function properly. You can set them in your .env file or export them directly in your terminal.
  • BROWSERBASE_API_KEY: Your API key from Browserbase dashboard
    • Required for authentication
    • Format: Starts with “bb_live_” or “bb_test_” followed by a unique string
  • BROWSERBASE_PROJECT_ID: The project ID from your Browserbase dashboard
    • Required to identify which project to use for browser sessions
    • Format: UUID string (8-4-4-4-12 format)
  • BROWSERBASE_BASE_URL: The Browserbase API endpoint

from agno.agent import Agent
from agno.tools.browserbase import BrowserbaseTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

# ==================== Usage ====================
# BrowserbaseTools automatically uses the correct implementation based on context:
# - Sync tools when using agent.run() or agent.print_response()
# - Async tools when using agent.arun() or agent.aprint_response()

agent = Agent(
    name="Web Automation Assistant",
    tools=[BrowserbaseTools()],
    instructions=[
        "You are a web automation assistant that can help with:",
        "1. Capturing screenshots of websites",
        "2. Extracting content from web pages",
        "3. Monitoring website changes",
        "4. Taking visual snapshots of responsive layouts",
        "5. Automated web testing and verification",
    ],
    markdown=True,
)

# ==================== Sync Usage ====================
# Use this for regular scripts and synchronous execution

# Content Extraction and SS
# agent.print_response("""
#     Go to https://news.ycombinator.com and extract:
#     1. The page title
#     2. Take a screenshot of the top stories section
# """)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("""
        Visit https://quotes.toscrape.com and:
        1. Extract the first 5 quotes and their authors
        2. Navigate to page 2
        3. Extract the first 5 quotes from page 2
    """)

    # ==================== Async Usage ====================
    # Use this for FastAPI, async frameworks, or when using agent.arun()
    # The same agent instance works for both sync and async - just use arun/aprint_response!

    # import asyncio
    #
    #
    # async def main():
    #     # Same agent, just use async methods - it will automatically use async tools
    #     await agent.aprint_response("""
    #         Visit https://quotes.toscrape.com and:
    #         1. Extract the first 5 quotes and their authors
    #         2. Navigate to page 2
    #         3. Extract the first 5 quotes from page 2
    #     """)
    #
    #
    # if __name__ == "__main__":
    #     asyncio.run(main())

Run the Example

# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools

# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate

python browserbase_tools.py
For details, see Browserbase cookbook.