Constructor Signature
- TypeScript
- Python
Parameters
Required Parameters
The environment to use for Stagehand.
BROWSERBASE- Run browser on Browserbase cloud infrastructureLOCAL- Run browser locally on your machine
"BROWSERBASE" (Python only)Browserbase Configuration
Your Browserbase API key. Required when
env is BROWSERBASE.Your Browserbase project ID. Required when
env is BROWSERBASE.The ID of an existing Browserbase session to resume. Useful for continuing previous browser sessions.
Parameters to use when creating a Browserbase session. See Browserbase API documentation for available options.
Wait for captchas to be solved after navigation when using Browserbase environment.Default:
falseLocal Browser Configuration
Configuration options for launching a local browser. Only used when
env is LOCAL.See the full interface definition for all available options.LLM Configuration
The LLM model to use for Stagehand operations.Examples:
gpt-4o, gpt-4o-mini, claude-3-5-sonnet-20241022Python Default: "gpt-4o"API key for the LLM model provider. Python only.In TypeScript, use
modelClientOptions.apiKey instead.The LLM provider to use for Stagehand. Custom provider implementation. TypeScript only.
Custom LLM client instance to use for Stagehand operations. TypeScript only.
LLM client configuration options. Useful for parameterizing LLM API keys and other settings.Common options:
apiKey (TypeScript), api_base, temperature, maxTokensEnable 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.The verbosity level of the Stagehand logger.
0- Minimal (ERROR only)1- Medium (INFO level)2- Detailed (DEBUG level)
1Custom logger function to handle log messages from Stagehand.
Whether to use Rich for colorized logging output. Python only.Default:
trueDisable Pino logger. Helpful for Next.js or test environments where Pino causes issues. TypeScript only.Default:
falseLog LLM inference details to a file for debugging purposes. TypeScript only.Default:
falsePerformance and Behavior
Default timeout to wait for the DOM to settle before performing operations.TypeScript Default:
10000 (10 seconds)
Python Default: 3000 (3 seconds)Enable self-healing capabilities to automatically recover from failures.Python Default:
trueCustomize the Stagehand system prompt used for LLM interactions.
Offload Stagehand method calls to the Stagehand API.Default:
trueEnable the latest experimental features. Use with caution in production.Default:
falseReturns InitResult
After calling stagehand.init(), you receive an InitResult object:
URL for debugging the browser session (e.g., Chrome DevTools).
URL of the browser session (especially useful with Browserbase).
Unique identifier for the browser session.

