Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

stagehand-claude-sdk

Give Claude a browser through the Anthropic SDK. StagehandBrowser implements Anthropic's browser toolset (browser_toolset_20260801) on top of Stagehand: all 31 members (navigation, screenshots, clicks and keyboard, page reading, forms, tabs, uploads, console and network), against a local Chrome, a Chromium you already run, or a Browserbase session. The Anthropic SDK runs the model's tool loop; this package runs the browser.

Quickstarts for TypeScript and Python, with local Chrome and Browserbase variants: browserbase/claude-cua-toolset.

Install

pip install stagehand-claude-sdk

Python 3.11 or later. The distribution is stagehand-claude-sdk; the import is stagehand_claude_sdk. It depends on an anthropic release that ships the browser toolset helpers. The Stagehand runtime this driver needs is bundled in the package (Stagehand 4.2.0a2), so there is nothing else to install. The package also installs the published stagehand for code that imports Stagehand directly; the driver always uses the bundled copy. Local browsers must be Chromium-based (Chrome, Chromium, Edge).

Quick start

The driver is async, so it pairs with AsyncAnthropic.

import asyncio

from anthropic import AsyncAnthropic
from stagehand_claude_sdk import StagehandBrowser


async def main() -> None:
    browser = await StagehandBrowser.launch(
        headless=False,  # watch the browser work; set True to hide it
        allowed_domains=["example.com", "iana.org"],
    )
    async with browser:  # closes the browser when the block exits; the tool runner never does
        runner = AsyncAnthropic().beta.messages.tool_runner(
            model="claude-sonnet-5-5",
            max_tokens=1024,
            tools=[browser],  # the toolset instance is the tools[] entry
            messages=[{"role": "user", "content": "Open example.com and tell me the page heading."}],
        )
        async for message in runner:
            print(message)


asyncio.run(main())

Other browsers:

await StagehandBrowser.browserbase(api_key=os.environ["BROWSERBASE_API_KEY"], allowed_domains=[...])  # a Browserbase session
await StagehandBrowser.connect(cdp_url="ws://127.0.0.1:9222/devtools/browser/...", allowed_domains=[...])  # a running Chromium

Without the runner, await browser.tool_result(tool_use) answers one browser tool_use block.

Options

The SDK's own toolset options pass through: configs, confirm, url_policy, file_policy, tool_configs. javascript_exec, file_upload, read_console and read_network are off unless enabled in configs, and javascript_exec / file_upload need a confirm callback.

Option What it does
allowed_domains / blocked_domains Hosts, IP literals or CIDR ranges. A domain entry includes its subdomains and the block list wins. Enforced inside the browser on every HTTP(S) request (navigations, sub-resources, redirects, popups) and checked on navigate before anything is sent.
upload_roots / download_dir Where file_upload may read from and downloads are written to (local browsers).
headless, chrome_path Local launch settings.

Limitations

  • Domain lists cover the browser's HTTP(S) requests and WebSocket handshakes, but they are not complete network isolation. Run untrusted tasks in an isolated browser and treat page content as untrusted.
  • Local browsers must be Chromium-based. Firefox and WebKit are not supported.
  • Downloads are not available in Browserbase sessions.
  • If the browser connection is lost, close the toolset and create a new instance.

Examples

See browserbase/claude-cua-toolset for runnable examples.

License

MIT. Includes Stagehand (MIT, Browserbase) under stagehand_claude_sdk/_vendor/stagehand.

Metadata

Release files for stagehand-claude-sdk 0.1.0rc2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stagehand-claude-sdk 0.1.0rc2
File Size Uploaded
stagehand_claude_sdk-0.1.0rc2.tar.gz 563.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stagehand-claude-sdk 0.1.0rc2
File Interpreter ABI Platform
stagehand_claude_sdk-0.1.0rc2-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / stagehand_claude_sdk-0.1.0rc2.tar.gz

Download URL stagehand_claude_sdk-0.1.0rc2.tar.gz
Size 563.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ec40ebb325570abec648796c9efe2e0aabb330f7bb80d3e9028a6470ae071da9
BLAKE2b-256 checksum
How to use checksums
d0912cc06e9866414bf7d648ef8b1a00099efcac06f1daa04ebb604a9c95fb89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / stagehand_claude_sdk-0.1.0rc2-py3-none-any.whl

Download URL stagehand_claude_sdk-0.1.0rc2-py3-none-any.whl
Size 582.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79d3fab2993ec1d64f364c135e4dab4041d939df915dfde53ac425e9c35f5b24
BLAKE2b-256 checksum
How to use checksums
041796f1970b0821cb2199b251b1c743674ba893bc9f4944243785e82e323480
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.1.0

2 release files

This release

0.1.0rc2 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page