Constructor Signature
- TypeScript
- Python
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 infrastructureLOCAL- Run browser locally on your machine
"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:
falseLocal 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, maxTokensboolean
Enable caching of LLM responses to reduce API calls and costs.TypeScript Default:
true
Python Default: falseLogging 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)
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:
trueboolean
Disable Pino logger. Helpful for Next.js or test environments where Pino causes issues. TypeScript only.Default:
falseboolean
Log LLM inference details to a file for debugging purposes. TypeScript only.Default:
falsePerformance 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:
truestring
Customize the Stagehand system prompt used for LLM interactions.
boolean
Offload Stagehand method calls to the Stagehand API.Default:
trueboolean
Enable the latest experimental features. Use with caution in production.Default:
falseReturns 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.

