session.stagehand.* or session.browserUse.* for AI-powered browsing. Stagehand provides structured extraction, actions, and observations. Browser-use provides autonomous task execution. The same capabilities are also exposed over HTTP via POST /v1/sessions/{id}/automation using calls like stagehand.act, stagehand.extract, stagehand.observe, stagehand.agent.execute, and browserUse.agent.execute.
Access
Quick Example
Methods
Stagehand
Stagehand provides structured AI interactions: perform actions, extract data, observe page elements, and run autonomous agents.stagehand.act()
Perform an action on the page using natural language or a structured action object fromobserve().
Accepts either a natural language instruction string or a
StagehandAction object returned by observe().Natural language instruction (e.g., “Click the login button”) or a structured action from
observe().Action options.
Action result with success status.
stagehand.extract()
Extract structured data from the page using natural language and a Zod schema. Without arguments, returns the raw page text.Call with no arguments for raw page text, or with an instruction + Zod schema for structured extraction.
What to extract (e.g., “product prices and names”).
Zod schema defining the expected output shape.
Extraction options.
Extracted data matching the schema, or raw page text if no schema provided.
stagehand.observe()
Observe the page and return a list of possible actions. Useful for discovering interactive elements before acting on them.Optional instruction to focus observation (e.g., “navigation links”).
Observation options.
Array of possible actions that can be passed to
act().stagehand.agent()
Create a reusable Stagehand agent for multi-step autonomous task execution.Agent configuration.
Agent instance with an
execute() method.agent.execute()
Execute an autonomous task with the Stagehand agent. The agent will observe, plan, and act across multiple steps.Task to accomplish.
Execution options.
Execution result with success status and action history.
stagehand.getMetrics()
Get performance metrics for Stagehand operations in the current session.Metrics including token usage, latency, and step counts.
stagehand.getHistory()
Get the action history for Stagehand operations in the current session.Array of past actions with timestamps and results.
Browser-use
Browser-use agents provide fully autonomous browsing with natural language task descriptions.browserUse.agent()
Create a reusable Browser-use agent for natural language task execution.Agent configuration.
Agent with an
execute() method.browserUse.codeAgent()
Create a code-based Browser-use agent that generates and executes automation code.Code agent configuration.
Code agent with an
execute() method.agent.execute()
Execute a natural language task autonomously. The agent navigates, clicks, fills forms, and extracts data to accomplish the task.Natural language task description.
Execution options.
Execution result.

