This documentation is automatically synced from the Python SDK GitHub repository.
Why Stagehand?
Most existing browser automation tools either require you to write low-level code in a framework like Selenium, Playwright, or Puppeteer, or use high-level agents that can be unpredictable in production. By letting developers choose what to write in code vs. natural language, Stagehand is the natural choice for browser automations in production.- Choose when to write code vs. natural language: use AI when you want to navigate unfamiliar pages, and use code (Playwright) when you know exactly what you want to do.
- Preview and cache actions: Stagehand lets you preview AI actions before running them, and also helps you easily cache repeatable actions to save time and tokens.
- Computer use models with one line of code: Stagehand lets you integrate SOTA computer use models from OpenAI and Anthropic into the browser with one line of code.
TL;DR: Automate the web reliably with natural language:
- act — Instruct the AI to perform actions (e.g. click a button or scroll).
- extract — Extract and validate data from a page using a Pydantic schema.
- observe — Get natural language interpretations to, for example, identify selectors or elements from the page.
- agent — Execute autonomous multi-step tasks with provider-specific agents (OpenAI, Anthropic, etc.).
Installation:
To get started, simply:We recommend using uv for your package/project manager. If you’re using uv can follow these steps:
Quickstart
Documentation
See our full documentation here.Cache Actions
You can cache actions in Stagehand to avoid redundant LLM calls. This is particularly useful for actions that are expensive to run or when the underlying DOM structure is not expected to change.Using observe to preview an action
observe lets you preview an action before taking it. If you are satisfied with the action preview, you can run it in page.act with no further LLM calls.
self_heal will run the loop again to save you from constantly updating your scripts.

