Skip to content
Browserbase
    • Primitives
      • BrowsersCloud browsers for your agent to use the web
      • AgentsScale fully managed browser agents with simple prompts
      • SearchFind relevant websites from a single query
      • FetchRetrieve web data as agent-ready HTML, JSON, or markdown
      • RuntimeScalable, sandboxed environments for agent deployments
      • IdentityAuthenticate your agent to navigate the web like a human
      • ModelsUse any model with a single API key
      • ObservabilityUnified debugging your agent across replays, logs, and prompts
    • Open Source
      • Browse CLIGive your agent browsing skills with a single command
      • StagehandThe most popular AI browser automation framework
    • Use Cases
      • Browser AgentsPower agents across logins, forms, and portals
      • Web Data ExtractionAutomate data extraction from sites with no APIs
      • Records VerificationCheck KYB, background, and title from official sources
      • Portal FilingsFile registrations, pay invoices, and submit appeals at scale
      • Document RetrievalCollect receipts, statements, and reports from vendor portals
      • Data MigrationImport a new customer's data from the system they're leaving
      • Permissioned Data AccessSecurely access payroll, HRIS, and patient portal accounts your users authorize
      • AI AssistantsBuild agents that act on behalf of your users
      All use cases
    • Industries
      • AI & Agent Platforms
      • Healthcare
      • Fintech
      • GTM
      • Legal
    • Resources
      • Blog
      • Customers
      • Enterprise
      • Templates
  • Pricing
  • Docs
  • Log in
Log in
Sign up
Get a demo

The quickest way to interact with the web.

Stagehand is an open source SDK to build performant and resilient web automation and AI Agents. Run it locally, or on Browserbase, at the same speed.

Read the docsView Github

One SDK for humans and AI Agents.

Use familiar APIs, self-healing actions, and network-level security across TypeScript, Python, and Go.

Same primitives as Playwright

Claude Code, Codex and yourself already know how to write 
Stagehand code, thanks to its shared primitives with Playwright.
Stagehand adds useful APIs for Shadow DOM, iframe support,
clipboard access and more.

Self-healing selectors

Stagehand’s act(), observe() and extract() shorthand removes
the brittleness of selectors, adapting to every web page change
and enable structured data extraction.

Remote browsers as fast as local ones.

Connecting your Stagehand program to Browserbase’s Browsers
ensures performance similar to local browsers.
Combining it with Browserbase’s Remote Cache and 
Model Gateway reduces token costs at scale.

Same API as Playwright, available in TypeScript, Python and Go

Stagehand shares the same common primitives as Playwright, making it easy for Claude Code and Codex to generate and for you to start using.

  1. Typescript
  2. Python
import { z } from "zod/v4";
import { localBrowser, Stagehand } from "@browserbasehq/stagehand";

const browser = await localBrowser.launch();
const sh = await Stagehand.create({ browser });

const page = await browser.context.activePage();
if (!page) throw new Error("Stagehand initialized without an active page");

await page.goto("https://news.ycombinator.com");

const result = await sh.extract(
  "Extract the top 5 stories",
  z.object({
    stories: z.array(
      z.object({
        title: z.string(),
        points: z.number(),
      }),
    ),
  }),
);

console.log(result.data.stories);

await sh.close();
await browser.close();
from pydantic import BaseModel
from stagehand import Stagehand, local_browser


class Story(BaseModel):
    title: str
    points: float


class Stories(BaseModel):
    stories: list[Story]


browser = await local_browser.launch()
sh = await Stagehand.create(browser=browser)

page = await browser.context.active_page()

await page.goto("https://news.ycombinator.com")

result = await sh.extract("Extract the top 5 stories", Stories)

print(result.data.stories)

await sh.close()
await browser.close()

Optimized for AI Agents

  • 80% more token efficient

    Stagehand consumes up to 80% fewer
tokens than Playwright, with APIs optimized for Claude Code and Codex to generate.

    Use Stagehand with Claude Code
  • Integrates with AI SDK, Mastra, Crew and more

    Stagehand integrates with your favorite AI frameworks, adding web browsing capabilities to your AI workflow or AI Agent application.

    Explore Stagehand integrations

Stagehand vs. Playwright

Shared primitives with additional APIs for Shadow DOM, iframe support, clipboard access and more

Comparing frameworks
FeatureStagehandPlaywright
Designed foragentstesting
Playwright-style APIYesYes
Faster runtime living in browserYesNo
Shadow DOM and iframe supportYesNo
Domain allow-list/block-listYesNo
Built-in OTel tracingYesNo
Batching commands supportYesNo

Deploy Stagehand at scale Browserbase

  • Remote browsers as fast as local ones

    Every Browserbase Browser comes with Stagehand preloaded, preventing unnecessary network roundtrips and resulting in near local browser performance.

    Explore Browsers
  • Cheaper at scale with caching

    Enable remote caching of act(), observe(), and extract() results server-side to reduce LLM costs and speed up your automations.

    Learn more about caching
  • Assign the right model to each action

    Combine Stagehand with Model Gateway to automatically pair the best model for each Stagehand actions, lowering inference cost by 30–40%.

    Learn more about Model Routing

Frequently Asked Questions

What is Stagehand?

Stagehand is an open-source SDK for building browser agents. It gives you three AI primitives, act(), extract(), and observe(), alongside the full Playwright-style page API, so you can mix natural language instructions with deterministic code in the same script. Stagehand is available in TypeScript, Python, and Go.

Is Stagehand free and open source?

Yes. Stagehand is open source under the MIT license and free to use with any Chromium browser on your own machine. Browserbase, which creates and maintains Stagehand, is a separate paid product for running browser agents in production. You never need a Browserbase account to use Stagehand.

How is Stagehand different from Playwright?

Playwright was built for testing, Stagehand is built for agents. Playwright depends on hardcoded selectors that break when a site changes its DOM, while Stagehand resolves instructions like "click the submit button" at runtime and self-heals. Stagehand keeps the Playwright API surface, so goto(), click(), and locator() work exactly as you expect.

Can I use Stagehand without Browserbase?

Yes. Stagehand runs locally out of the box against any Chromium browser, and the full SDK is available without an account. Connecting to Browserbase adds hosted browsers, session replay, server-side caching, the Model Gateway, and Verified access, which is what most teams move to when they go to production.

What languages does Stagehand support?

Stagehand ships first-class SDKs for TypeScript, Python, and Go, with feature parity across all three. v4 achieves parity by moving the shared core into the browser runtime instead of reimplementing it per language, so a feature that lands in one SDK lands in all three.

Which LLMs does Stagehand work with?

Stagehand is model-agnostic. You can name a supported provider directly or supply your own client-side LLM callback, which means you can run Claude, GPT, Gemini, or a local model without changing your automation code. On Browserbase, the Model Gateway routes every model through one API key.

What is new in Stagehand v4?

Stagehand v4 moves the runtime into the browser itself, so state, target management, and CDP dispatch live alongside the page instead of in your client. That change delivers roughly 2x faster wall-clock time on a 50-action crawl, uniform handling of cross-origin and nested iframes, shadow DOM support including closed roots, real clipboard access, WebMCP, and domain policy enforced before requests leave the browser.

Do I need to migrate from Stagehand v3 to v4?

v4 introduces breaking changes, so v3 scripts need updating. The main ones: construction moves to Stagehand.create({ browser }), act(), extract(), and observe() move from the page to the Stagehand instance, all calls now return { data, metadata }, agent() is removed in favour of code mode or tool calling, and deepLocator() folds into locator(). The migration guide covers each change with before and after code.

Does Stagehand break when a website changes?

Stagehand is designed to survive DOM changes that break traditional scripts. Because act() and observe() resolve intent at runtime rather than matching a stored CSS selector, a redesigned page usually keeps working without code changes. For steps where you need guaranteed behavior, you can drop to deterministic Playwright-style selectors in the same script.

How much does running Stagehand cost?

Stagehand itself is free and open source. Your cost is the LLM inference for act(), extract(), and observe() calls, which you control by choosing your own model. Running on Browserbase adds server-side caching that replays resolved actions instead of re-inferring them, cutting cost on repeated runs.

Can I use Stagehand for testing?

You can, but it is not what v4 optimizes for. Stagehand is built for agents that operate on live production websites they do not control, where the DOM changes without warning. If your target is your own app in CI with a stable DOM, Playwright remains the better fit.

What will you build?

Deploy on BrowserbaseRead the docs
Browserbase

Primitives

  • Browsers
  • Web APIs
  • Runtime
  • Identity
  • Model Gateway
  • Observability
  • Stagehand
  • MCP

Industries

  • AI
  • Healthcare
  • GTM
  • Tax
  • Legal

Developers

  • Docs
  • Templates
  • APIs & SDKs
  • Changelog
  • Status
  • Github

Company

  • Careers
  • Customers
  • Partner with Us
  • Trust & Security

Community

TwitterLinkedinYoutube
  • Privacy Policy
  • Terms of Service

Community

TwitterLinkedinYoutube
  • Privacy Policy
  • Terms of Service