specstream-claude-browser
A driver for the browser toolset of the Claude SDK that runs on SpecStream browser sessions. Claude navigates, reads and acts in a real browser that SpecStream hosts. You run no browser yourself.
pip install specstream-claude-browser
Quick start
A free account comes with $2 of credit and needs no card: specstream.ai.
Set ANTHROPIC_API_KEY, SPECSTREAM_API_KEY, and CLAUDE_MODEL to a model the browser toolset supports (the Claude page above lists them). Create a SpecStream key under Agents & API at https://specstream.ai/workspace.
import os
from anthropic import Anthropic
from specstream_claude_browser import SpecStreamBrowser
client = Anthropic()
with SpecStreamBrowser() as browser:
runner = client.beta.messages.tool_runner(
model=os.environ["CLAUDE_MODEL"], # a model the browser toolset supports
max_tokens=1024,
tools=[browser],
messages=[{"role": "user", "content": "Open example.com and tell me its heading."}],
)
for message in runner:
print(message)
The session opens at the first call and ends when the with block ends. A toolset that Claude never calls opens no session.
What it costs
A session costs $0.10 an hour, charged by the second, plus $1 per 1,000 steps. One member call is one step, with three exceptions: key is one step for each key press, form_input on a text field or a select is two steps, and a refused call is none.
Members
| Member | How it runs |
|---|---|
navigate |
Opens the URL. back, forward and reload work. The HTTP status is not reported. |
screenshot |
A PNG of the viewport. One image pixel is one CSS pixel. |
read_page |
The page's accessibility snapshot. Each element carries a ref, such as [ref=e12]. |
get_page_text |
The page's text. |
find |
The snapshot lines that contain the words of the query. It matches text, not a description. |
left_click, double_click, right_click, middle_click, hover |
By ref, with the pointer. left_click also takes a coordinate, and then clicks the element at that point by script. |
scroll, scroll_to |
scroll moves the scrollable box under the point. scroll_to brings a ref into view. |
type |
Inserts text into the field that has the focus. |
key |
Keys and chords as Claude writes them (ctrl+a, Return). |
form_input |
Fills a text field, chooses an option of a select, or sets a checkbox, by ref. |
wait |
Waits up to 60 seconds. |
read_console, read_network |
The page's console messages and network requests. |
javascript_exec |
Runs a script in the page. Served only when you pass confirm. |
Not served, and sent to the API as disabled: zoom, left_click_drag, left_mouse_down, left_mouse_up, mouse_move, hold_key, file_upload, new_tab, switch_tab, list_tabs and close_tab. The driver follows one page and reports it as one tab.
Options
SpecStreamBrowser(
api_key=None, # default: the SPECSTREAM_API_KEY environment variable
session_id=None, # drive a session that is already open, and leave it open at close()
timeout_s=900, # the longest the session lasts, 60 to 3600 seconds
idle_timeout_s=300, # the session ends after this long without a step, 10 to 600 seconds
allowed_domains=None, # hosts the session may open, such as ["example.com", "*.example.com"]
block_media=False, # do not load images, video and fonts
url_policy=..., # the toolset's own options are passed through:
confirm=..., # url_policy, confirm, configs, file_policy, tool_configs
)
browser.session_id is the session's id once it is open. browser.live_url is a page that shows the browser's screen as it changes.
Run it safely
Claude's next action depends on the pages it reads, and a page can try to steer it. Before you run the driver on anything that matters, read Run the toolset safely and do these two things:
- Pass
allowed_domains. The session itself then refuses every other host, also for links a page opens. Aurl_policychecks only the URLs Claude navigates to. - Pass
confirmfor calls that have an effect, and leavejavascript_execoff unless the task needs it.
SpecStream sessions never open private addresses, and they do not open sites that opted out.
Errors
A step that fails reaches Claude as an error result with SpecStream's own message, and the run continues. That includes a key that SpecStream refuses. A missing key raises SpecStreamError when you create the toolset. close() does not raise: if the release call fails, the session ends at its idle wait.
Tests
pip install -e ".[test]"
pytest -q
The tests script the SpecStream API. They need no key and no network.
License
BSD-2-Clause.
Metadata
Release files for specstream-claude-browser 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| specstream_claude_browser-0.1.0.tar.gz | 15.3 kB | Without provenance | Details for specstream_claude_browser-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| specstream_claude_browser-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for specstream_claude_browser-0.1.0-py3-none-any.whl |
Total release size: 28.3 kB
Release files / specstream_claude_browser-0.1.0.tar.gz
| Download URL | specstream_claude_browser-0.1.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e819794efcf50159c8dd1ff0bdbc730090f19c0dad6f3ed03a986bdd38824c3
|
|
BLAKE2b-256 checksum How to use checksums |
e083f8d4ef9c0a68ab6de6cde080f716fcac50288d148f64e1b97a0d1259f322
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / specstream_claude_browser-0.1.0-py3-none-any.whl
| Download URL | specstream_claude_browser-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e58912dc0fe6c57148e416683a9bfee39b26e301135d41e537867bd185a584e9
|
|
BLAKE2b-256 checksum How to use checksums |
20dba0ee29499da30cc5b5e9509d8adde41e28f8f10dcd63746bbf8245235173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for specstream-claude-browser 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.