- Notifications
You must be signed in to change notification settings - Fork802
The AI Browser Automation Framework
License
browserbase/stagehand
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The AI Browser Automation Framework
Read the Docs
If you're looking for the Python implementation, you can find it here
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.
Here's how to build a sample browser automation with Stagehand:
// Use Playwright functions on the page objectconstpage=stagehand.page;awaitpage.goto("https://github.com/browserbase");// Use act() to execute individual actionsawaitpage.act("click on the stagehand repo");// Use Computer Use agents for larger actionsconstagent=stagehand.agent({provider:"openai",model:"computer-use-preview",});awaitagent.execute("Get to the latest PR");// Use extract() to read data from the pageconst{ author, title}=awaitpage.extract({instruction:"extract the author and title of the PR",schema:z.object({author:z.string().describe("The username of the PR author"),title:z.string().describe("The title of the PR"),}),});
Visitdocs.stagehand.dev to view the full documentation.
Start with Stagehand with one line of code, or check out ourQuickstart Guide for more information:
npx create-browser-app
git clone https://github.com/browserbase/stagehand.gitcd stagehandpnpm installpnpm playwright installpnpm run buildpnpm run example# run the blank script at ./examples/example.tspnpm run example 2048# run the 2048 example at ./examples/2048.ts
Stagehand is best when you have an API key for an LLM provider and Browserbase credentials. To add these to your project, run:
cp .env.example .envnano .env# Edit the .env file to add API keys
Note
We highly value contributions to Stagehand! For questions or support, please join ourSlack community.
At a high level, we're focused on improving reliability, speed, and cost in that order of priority. If you're interested in contributing, we strongly recommend reaching out toMiguel Gonzalez orPaul Klein in ourSlack community before starting to ensure that your contribution aligns with our goals.
For more information, please see ourContributing Guide.
This project heavily relies onPlaywright as a resilient backbone to automate the web. It also would not be possible without the awesome techniques and discoveries made bytarsier,gemini-zod, andfuji-web.
We'd like to thank the following people for their major contributions to Stagehand:
Licensed under the MIT License.
Copyright 2025 Browserbase, Inc.
About
The AI Browser Automation Framework
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.