{"library":"stagehand","title":"Stagehand","type":"library","description":"Stagehand is an AI-powered browser automation framework that allows controlling web browsers using natural language instructions and code. It is built on top of Playwright but integrates an intelligent agent to interpret high-level commands, making web automations more resilient and maintainable by reducing reliance on brittle CSS selectors. The Python library (stagehand-py) provides an official SDK for interacting with the Stagehand API, supporting both local browser environments and cloud execution via Browserbase. It is currently at version 3.19.5 and has a rapid release cadence.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install stagehand"],"cli":null},"imports":["from stagehand.sync import Stagehand","from stagehand import StagehandConfig"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://stagehand.dev","github":"https://github.com/browserbase/stagehand-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/stagehand/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import os\nfrom stagehand.sync import Stagehand\nfrom stagehand import StagehandConfig\n\n# Ensure BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID are set in your environment\n# For local mode, set env=\"LOCAL\" and ensure a Chromium browser is installed.\napi_key = os.environ.get('BROWSERBASE_API_KEY', 'your_browserbase_api_key_here')\nproject_id = os.environ.get('BROWSERBASE_PROJECT_ID', 'your_browserbase_project_id_here')\n\nif not api_key or not project_id:\n    print(\"Warning: BROWSERBASE_API_KEY or BROWSERBASE_PROJECT_ID not found. \\n\"\\\n          \"Using placeholder values. For full functionality, set these environment variables.\")\n\ntry:\n    # Initialize Stagehand client for Browserbase cloud environment\n    config = StagehandConfig(\n        env=\"BROWSERBASE\",\n        api_key=api_key,\n        project_id=project_id\n    )\n    stagehand = Stagehand(config=config)\n    print(\"Stagehand client initialized.\")\n\n    # Navigate to a page\n    print(\"Navigating to example.com...\")\n    page = stagehand.context.pages()[0] # Get the default page\n    page.goto(\"https://www.example.com\")\n    print(\"Navigation complete.\")\n\n    # Use natural language to interact (act) and extract data\n    print(\"Performing an action: clicking a link...\")\n    # This 'act' command will try to find a link and click it\n    # For a deterministic action on example.com, a more specific instruction might be needed.\n    # For demonstration, we'll try a generic act.\n    # In a real scenario, you'd specify something like \"click the 'More information...' link\"\n    # if it existed and was prominent.\n    try:\n        page.act(\"click the first link on the page\")\n        print(\"Clicked the first link.\")\n    except Exception as e:\n        print(f\"Could not perform 'act' on a link: {e}\")\n        print(\"Continuing with extraction.\")\n\n    print(\"Extracting page heading...\")\n    # Extract the main heading using natural language\n    heading = page.extract(\"the main heading on the page\")\n    print(f\"Extracted heading: {heading}\")\n\n    # End the session\n    stagehand.close()\n    print(\"Stagehand session closed.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure you have a valid Browserbase API key and project ID, or configure for local mode.\")","lang":"python","description":"This quickstart demonstrates how to initialize the Stagehand client, navigate to a URL, and perform AI-powered actions like clicking and extracting information using natural language instructions. It's configured for the Browserbase cloud environment, requiring `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`. For local execution, `env=\"LOCAL\"` can be set in `StagehandConfig`, but a Chromium-based browser must be installed and accessible.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"3.20.0","pypi_latest":"3.20.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":4.8,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"stagehand","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"32.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"stagehand","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.2,"import_time_s":null,"mem_mb":null,"disk_size":"139M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"stagehand","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"36.1M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"stagehand","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.7,"import_time_s":null,"mem_mb":null,"disk_size":"142M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"stagehand","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"27.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"stagehand","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4,"import_time_s":null,"mem_mb":null,"disk_size":"134M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"stagehand","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"27.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"stagehand","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4,"import_time_s":null,"mem_mb":null,"disk_size":"134M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"stagehand","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"32.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"stagehand","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.9,"import_time_s":null,"mem_mb":null,"disk_size":"139M"}]}}