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. 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=True, 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.0rc1

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.0rc1
File Size Uploaded
stagehand_claude_sdk-0.1.0rc1.tar.gz 563.2 kB Details

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / stagehand_claude_sdk-0.1.0rc1.tar.gz

Download URL stagehand_claude_sdk-0.1.0rc1.tar.gz
Size 563.2 kB
Tags Source
SHA-256 checksum
How to use checksums
634d2283d11447fce90135a34b7eb9130ad3576029ec338ef013a359e6063944
BLAKE2b-256 checksum
How to use checksums
82b6030f04ccf2552c10ad725e2d692bde76435872ead816620196b1de0b874b
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.0rc1-py3-none-any.whl

Download URL stagehand_claude_sdk-0.1.0rc1-py3-none-any.whl
Size 582.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7d62f22579c1ddc5fb2912ea40b1f50cac45c4fe580218b5a52784800a7ba7c
BLAKE2b-256 checksum
How to use checksums
4dce198676de46bfd1aaa4b06d667a252773079c83b0e4b034386cce8ceca089
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.0rc1 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