StagehandBrowser. The Anthropic SDK runs the model’s tool loop, and Stagehand handles browser interactions such as navigation, screenshots, and form input.
Prerequisites
- An Anthropic API key and access to a model that supports the browser toolset.
- Google Chrome for the local example, or a Browserbase API key for a hosted session.
- Node.js 22.18 or later and pnpm for TypeScript, or Python 3.11 or later and uv for Python.
Install the integration
Clone the Claude Toolset repository:- TypeScript
- Python
Install the Anthropic SDK and Stagehand from npm:Import the driver from the
stagehand-claude-sdk npm package.Run a browser task
Export your Anthropic API key:example.ts or example.py with the matching example below. Both launch headless Chrome, ask Claude to read the heading on example.com, and print the model’s messages.
- TypeScript
- Python
example.ts
typescript directory:tools; the Anthropic SDK dispatches its browser tool calls. Keep the same instance throughout the loop so tabs and page state remain available.
The tool runner doesn’t close the browser. Use finally in TypeScript or async with browser in Python to close it when the task finishes or fails.
Use Browserbase
Export your Browserbase API key:StagehandBrowser.launch call with the matching factory below. Keep the tool loop and cleanup code from the previous example.
- TypeScript
- Python
Domain restrictions
SetallowedDomains and blockedDomains in TypeScript, or allowed_domains and blocked_domains in Python, to restrict HTTP and HTTPS requests. Entries match exact hosts by default; use a leading *. pattern such as *.example.com for subdomains. Blocked entries take precedence.
Troubleshooting
For additional configuration and examples, see the Claude Toolset repository.

