diff --git a/docs/references/constructor.mdx b/docs/references/constructor.mdx index 52da1ff34..aca8f132d 100644 --- a/docs/references/constructor.mdx +++ b/docs/references/constructor.mdx @@ -258,127 +258,3 @@ After calling `stagehand.init()`, you receive an `InitResult` object: Unique identifier for the browser session. - -### Code Examples - - - - - -```typescript TypeScript -import { Stagehand } from "@browserbasehq/stagehand"; - -const stagehand = new Stagehand({ - env: "BROWSERBASE", - apiKey: process.env.BROWSERBASE_API_KEY, - projectId: process.env.BROWSERBASE_PROJECT_ID, - verbose: 1, -}); - -const { sessionUrl } = await stagehand.init(); -console.log(`View session at: ${sessionUrl}`); -``` - -```python Python -from stagehand import Stagehand -import os - -stagehand = Stagehand( - env="BROWSERBASE", - api_key=os.environ["BROWSERBASE_API_KEY"], - project_id=os.environ["BROWSERBASE_PROJECT_ID"], - verbose=1, -) - -result = await stagehand.init() -print(f"View session at: {result.session_url}") -``` - - - - - - -```typescript TypeScript -import { Stagehand } from "@browserbasehq/stagehand"; - -const stagehand = new Stagehand({ - env: "LOCAL", - verbose: 2, - localBrowserLaunchOptions: { - headless: false, - }, -}); - -const { debugUrl, sessionId } = await stagehand.init(); -console.log(`Session: ${sessionId}`); -``` - -```python Python -from stagehand import Stagehand - -stagehand = Stagehand( - env="LOCAL", - verbose=2, - local_browser_launch_options={ - "headless": False, - }, -) - -result = await stagehand.init() -print(f"Session: {result.session_id}") -``` - - - - - - -```typescript TypeScript -import { Stagehand } from "@browserbasehq/stagehand"; - -const stagehand = new Stagehand({ - env: "LOCAL", - modelName: "gpt-4o", - domSettleTimeoutMs: 15000, - enableCaching: true, - selfHeal: true, - experimental: true, - localBrowserLaunchOptions: { - headless: false, - args: ['--no-sandbox', '--disable-setuid-sandbox'], - viewport: { width: 1920, height: 1080 }, - ignoreHTTPSErrors: true, - }, - systemPrompt: "You are a helpful web automation assistant.", - logInferenceToFile: true, -}); - -await stagehand.init(); -``` - -```python Python -from stagehand import Stagehand - -stagehand = Stagehand( - env="LOCAL", - model_name="gpt-4o", - dom_settle_timeout_ms=15000, - enable_caching=True, - self_heal=True, - experimental=True, - local_browser_launch_options={ - "headless": False, - "args": ['--no-sandbox', '--disable-setuid-sandbox'], - "viewport": {"width": 1920, "height": 1080}, - "ignore_https_errors": True, - }, - system_prompt="You are a helpful web automation assistant.", -) - -await stagehand.init() -``` - - - -