Skip to main content

Overview

Stagehand is an AI-powered browser automation framework with methods like observe(), extract(), and act(). This guide walks you through deploying and running a Stagehand project on Intuned. You’ll build a sample scraper that extracts book data—without writing Playwright selectors or custom parsing logic. The same patterns apply to any automation you build with the framework.
This guide assumes you have a basic understanding of Intuned projects. If you’re new to Intuned, start with the getting started guide.

When to use AI automation

Intuned supports AI-powered browser automation frameworks like Stagehand, Browser Use, and others. Use AI automation when:
  • Pages are dynamic — Elements change position, structure, or content unpredictably
  • You don’t know the exact page structure — Scraping sites you haven’t mapped in detail
  • You want natural language control — Describe what to do instead of writing precise selectors
  • Traditional Playwright code is too brittle for your case — AI agents adapt to minor UI changes automatically
Stagehand is one option for AI automation on Intuned. The setup patterns in this guide apply to other AI frameworks as well. For a deeper dive into choosing between deterministic, AI-driven, and hybrid approaches, check out Flexible Automations.

Guide

Let’s build a getBooks API with AI. The template handles all the Stagehand setup for you. You can develop with Stagehand in two ways:
  • Online IDE — Zero setup. Write, test, and deploy directly from your browser.
  • CLI — Use your favorite IDE with full version control.
1

Create a project

  1. Go to Intuned dashboard
  2. Select + New Project > Templates > Stagehand
  3. Select your language (Python or TypeScript)
  4. Name it and select Create Project
Create Stagehand project from template
2

Explore the project

The template includes a book scraper API that combines Playwright with AI agents.Project structure:
The automation code:
Python
What this does: Navigates to https://books.toscrape.com, uses Stagehand’s observe() and act() methods to navigate to a specific category, then uses extract() to collect book details across multiple pages. TypeScript uses Zod schemas; Python uses a JSON schema dict validated into Pydantic models.
3

Run your automation

Run the book scraper to test your setup.
  1. In the Online IDE, select the API from the dropdown
  2. Select Select Parameter and enter {"category": "Travel"}
  3. Select Start Run
Running Stagehand automation in IDE
4

Deploy and test

Deploy your automation to Intuned’s infrastructure.
  1. In the Online IDE, select Deploy in the top-right corner
  2. After deployment completes, go to the project’s Runs page
  3. Select Start Run, then choose your API
  4. Enter parameters: {"category": "Travel"} and select Start Run
Running Stagehand automation in Dashboard
  1. After the run completes, view the extracted results
View Stagehand run results

How it works

  • The setupContext hook stores the CDP URL in attemptStore for your API to access
Check out our setup hook recipe.
  • Your API initializes Stagehand with the CDP URL and AI gateway credentials from getAiGatewayConfig()
  • Stagehand provides three core AI-powered methods:
    • observe() - Find elements on the page using natural language
    • act() - Perform actions like clicking using natural language
    • extract() - Extract structured data from the page with type-safe schemas
  • Passes AI credentials via the model config (modelName, apiKey, baseURL)
  • Call methods directly on stagehand (e.g., stagehand.act(), stagehand.extract())
  • Use the Playwright page for navigation (e.g., page.goto())
  • Your API accepts parameters (like category) that can vary for each run
  • The automation handles pagination automatically and cleans up Stagehand when done

Stagehand Documentation

Official Stagehand documentation and API reference

Stagehand GitHub

View the source code and contribute to Stagehand

Intuned Cookbook

Browse examples and recipes for Intuned projects

attemptStore Reference

Learn more about sharing data between hooks and APIs