Skip to main content

Constructor Signature

ConstructorParams Interface:

Model Configuration

Learn how to configure different LLM models for Stagehand

Parameters

Required Parameters

'BROWSERBASE' | 'LOCAL'
required
The environment to use for Stagehand.
  • BROWSERBASE - Run browser on Browserbase cloud infrastructure
  • LOCAL - Run browser locally on your machine
Default: "BROWSERBASE" (Python only)

Browserbase Configuration

string
Your Browserbase API key. Required when env is BROWSERBASE.
string
Your Browserbase project ID. Required when env is BROWSERBASE.
string
The ID of an existing Browserbase session to resume. Useful for continuing previous browser sessions.
object
Parameters to use when creating a Browserbase session. See Browserbase API documentation for available options.
boolean
Wait for captchas to be solved after navigation when using Browserbase environment.Default: false

Local Browser Configuration

LocalBrowserLaunchOptions
Configuration options for launching a local browser. Only used when env is LOCAL.See the full interface definition for all available options.

LLM Configuration

Model Configuration

Learn how to configure different LLM models for Stagehand
AvailableModel
The LLM model to use for Stagehand operations.Examples: gpt-4o, gpt-4o-mini, claude-sonnet-4-6Python Default: "gpt-4o"
string
API key for the LLM model provider. Python only.In TypeScript, use modelClientOptions.apiKey instead.
LLMProvider
The LLM provider to use for Stagehand. Custom provider implementation. TypeScript only.
LLMClient
Custom LLM client instance to use for Stagehand operations. TypeScript only.
ClientOptions
LLM client configuration options. Useful for parameterizing LLM API keys and other settings.Common options: apiKey (TypeScript), api_base, temperature, maxTokens
boolean
Enable caching of LLM responses to reduce API calls and costs.TypeScript Default: true Python Default: false

Logging and Debugging

Security tip: Use verbose: 0 when your automation handles secrets to prevent sensitive data from appearing in logs.
0 | 1 | 2
The verbosity level of the Stagehand logger.
  • 0 - Minimal (ERROR only)
  • 1 - Medium (INFO level)
  • 2 - Detailed (DEBUG level)
Default: 1
(message: LogLine) => void | Promise<void>
Custom logger function to handle log messages from Stagehand.
boolean
Whether to use Rich for colorized logging output. Python only.Default: true
boolean
Disable Pino logger. Helpful for Next.js or test environments where Pino causes issues. TypeScript only.Default: false
boolean
Log LLM inference details to a file for debugging purposes. TypeScript only.Default: false

Performance and Behavior

number
Default timeout to wait for the DOM to settle before performing operations.TypeScript Default: 10000 (10 seconds) Python Default: 3000 (3 seconds)
boolean
Enable self-healing capabilities to automatically recover from failures.Python Default: true
string
Customize the Stagehand system prompt used for LLM interactions.
boolean
Offload Stagehand method calls to the Stagehand API.Default: true
boolean
Enable the latest experimental features. Use with caution in production.Default: false

Returns InitResult

After calling stagehand.init(), you receive an InitResult object:
string
required
URL for debugging the browser session (e.g., Chrome DevTools).
string
required
URL of the browser session (especially useful with Browserbase).
string
required
Unique identifier for the browser session.