Browser Use Python SDK

3.4.3 · active · verified Fri Apr 10

The `browser-use-sdk` is the official Python SDK for the Browser Use Cloud API, enabling AI agents to automate complex web tasks. It provides state-of-the-art browser automation with features like stealth browsers, CAPTCHA solving, and residential proxies, allowing for data extraction, form filling, multi-step workflows, and research. The current version is 3.4.3, and it maintains an active release cadence with frequent updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `AsyncBrowserUse` client and execute a natural language task. It expects the `BROWSER_USE_API_KEY` to be set as an environment variable. The `client.run()` method initiates an AI agent to perform the specified web automation task and returns the result.

import asyncio
import os
from browser_use_sdk.v3 import AsyncBrowserUse

async def main():
    api_key = os.environ.get('BROWSER_USE_API_KEY', '')
    if not api_key:
        print("Error: BROWSER_USE_API_KEY environment variable not set.")
        print("Please get your API key at cloud.browser-use.com/settings and set it.")
        return

    # The SDK automatically picks up BROWSER_USE_API_KEY from environment variables.
    # Alternatively, pass it explicitly: client = AsyncBrowserUse(api_key=api_key)
    client = AsyncBrowserUse()
    
    try:
        # Run an AI agent task with natural language instructions
        result = await client.run("Find the top 3 trending repositories on GitHub today and list their names and URLs")
        print("Agent Output:", result.output)
    except Exception as e:
        print(f"An error occurred during agent execution: {e}")

if __name__ == "__main__":
    asyncio.run(main())

view raw JSON →