> ## Documentation Index
> Fetch the complete documentation index at: https://docs.notte.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Stagehand

> Connecting Stagehand to Notte cloud browsers

<Tip>
  STOP. Do not read past this section until you have read and followed [/quickstart.md](/quickstart.md).

  Goal: produce a reliable SDK automation script. The intended authoring flow is generate then edit, not write browser automation from scratch.

  Do not hand-write SDK code with element IDs, selectors, or form fields from memory. Element IDs, selectors, and field mappings must come from a live `observe()` call, CLI `notte page observe` output, or generated workflow code. Guessed browser targets fail on real pages.

  Use the Notte skill and CLI to inspect the live site, validate actions/selectors, handle auth/session state, and export workflow code with `notte sessions workflow-code` before using SDK docs or SDK code.

  SDK reference pages are for understanding, running, or editing generated workflow code. They are not the starting point for manually authoring the initial browser automation. SDK-first code is guesswork on real-world pages with dynamic selectors, auth state, CAPTCHAs, and anti-bot behavior.
</Tip>

[Stagehand](https://github.com/browserbase/stagehand) is an open source AI browser automation framework that lets you choose what to write in code and what to write in natural language.

<Warning>
  Stagehand v4 does not currently work against Notte cloud browsers. On `initialize()` it installs a helper extension over CDP, and Notte sessions reject extension management:

  ```
  CDP operation 'Extensions.loadUnpacked' is not permitted in Notte Cloud sessions.
  ```

  This affects both the Python and the TypeScript SDK, and there is no client-side flag that skips the extension. Until Notte can preload the helper extension, use [Browser Use](/integrations/browser-use), [Playwright](/features/sessions/playwright), or a [Notte agent](/concepts/agents) instead.
</Warning>

## How the connection is meant to work

Stagehand takes a CDP URL through `local_browser.connect()`, so a Notte session plugs in with `session.cdp_url()`:

```python notte_stagehand.py theme={null}
async def main():
    client = NotteClient()

    with client.Session() as session:
        # Stagehand attaches to the Notte browser over CDP
        stagehand = Stagehand(
            browser=await local_browser.connect(cdp_url=session.cdp_url()),
            model="anthropic/claude-sonnet-4-5-20250929",
            api_key=os.environ.get("ANTHROPIC_API_KEY"),
        )
        await stagehand.initialize()
        print(await stagehand.extract("the title of the top story"))
        await stagehand.close()


asyncio.run(main())
```

The equivalent in TypeScript is `localBrowser.connect({ cdpUrl })` from `@browserbasehq/stagehand`.

<Note>
  Earlier versions of this page showed `Stagehand(env="LOCAL", local_browser_launch_options={...})`. That API belonged to Stagehand v2 and is not present in any release currently on PyPI - neither `stagehand` v3/v4 nor `stagehand-py`.
</Note>

## What to use instead

<CardGroup cols={2}>
  <Card title="Browser Use" icon="robot" href="/integrations/browser-use">
    An LLM driving a Notte browser over CDP, working today
  </Card>

  <Card title="Browser Agents" icon="wand-magic-sparkles" href="/concepts/agents">
    Hand the whole task to a Notte agent
  </Card>

  <Card title="Connect with Playwright" icon="p" href="/features/sessions/playwright">
    Write the automation yourself against a Notte session
  </Card>

  <Card title="Fetch" icon="download" href="/concepts/scraping">
    Pull structured data out of a page without an agent
  </Card>
</CardGroup>
