browser-use-turnstile
Let a browser-use agent solve Cloudflare Turnstile. One call registers a solve_cloudflare_turnstile action on your agent's tools. When the agent lands on a page blocked by a Turnstile widget, it calls the action, which reads the sitekey from the page, gets a token from Peak, and writes the token back into the form.
A browser-use agent clicks the Turnstile checkbox, the widget decides it is not a person, and the run stalls on a form that will not submit. The model cannot fix that by reasoning harder. The token has to be minted outside the browser. This package gives the agent that move as a tool.
The action takes no arguments. The agent does not have to find the sitekey or paste a token. The action does both against the live page.
Install
pip install browser-use-turnstile
browser-use needs Python 3.11 or newer, so this package does too.
Use it
from browser_use import Agent, ChatAnthropic, Tools
from browser_use_turnstile import register_turnstile_action
tools = Tools()
register_turnstile_action(tools) # reads PEAK_API_KEY from the environment
agent = Agent(
task="Open https://example.com/login, clear any Turnstile challenge, submit the form.",
llm=ChatAnthropic(model="claude-sonnet-5-5"),
tools=tools,
)
await agent.run()
Pass the key directly with register_turnstile_action(tools, api_key="pk_...") if you do not want the environment variable. A runnable version is in examples/basic_agent.py.
What the action does
- Reads the sitekey from the current page:
[data-sitekey]first, then thechallenges.cloudflare.comiframesrcfor widgets rendered through the JS API. - Sends the sitekey and the page URL to Peak.
- Fills every
cf-turnstile-responsefield with the token, firesinputandchange, and calls the widget'sdata-callbackif the page registered one. - Tells the agent what happened in one line, so its next step is "click Submit" and not a guess.
Failures come back as an error result the model can read (no sitekey on the page, no balance, bad key) instead of an exception that ends the run.
Matching the exit IP
Turnstile scores the IP that submits the token. If your browser runs behind a proxy, pass the same one:
register_turnstile_action(tools, proxy="http://user:pass@host:port")
Without proxy, the solve goes through Peak's own IP pool. That works for most sites and fails on the ones that bind the token to the requesting IP.
Use the pieces on their own
from browser_use_turnstile import PeakClient, solve_on_page
client = PeakClient("pk_...")
token = client.solve(sitekey="0x4AAAAAAA...", url="https://example.com/login")
solve_on_page(page, url, client) is the same logic the action runs, for use inside your own custom action.
Getting a key
The action needs an API key for the solver it calls: Peak. Turnstile solves come back in about a second, you pay only for the ones that land, and the free trial is enough to wire this up and test it.
For Cloudflare Turnstile, Cloudflare 5s challenge, AWS WAF, and DataDome:
API-first · $0.35 – $1.00 / 1K · volume tiers · pay only on success · peak.fo
Related
Other agent and browser wrappers for the same API: langchain-turnstile · crewai-turnstile · playwright-turnstile · nodriver-turnstile · camoufox-turnstile.
Notes
Use this on sites and accounts you are allowed to automate. Respect each target's Terms of Service and robots.txt. This is tooling for legitimate agents, testing, and public-data access. Nothing here helps with credential stuffing or abuse. Not affiliated with Cloudflare or browser-use.
License
MIT
Metadata
Release files for browser-use-turnstile 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 | |
|---|---|---|---|---|
| browser_use_turnstile-0.1.0.tar.gz | 8.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| browser_use_turnstile-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.7 kB
Release files / browser_use_turnstile-0.1.0.tar.gz
| Download URL | browser_use_turnstile-0.1.0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c5fe6c34cfe933e718e0ee05dbfb81cc70716eba7c0cc2951d56a8f3e390b35
|
|
BLAKE2b-256 checksum How to use checksums |
3e8d98e12adcd131064febda9ba2446a129ea33cebca7d31d39bfd949392d6b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Release files / browser_use_turnstile-0.1.0-py3-none-any.whl
| Download URL | browser_use_turnstile-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70b729f6853c8ea00f777303f217a0cd73d74f2de186999c07a5c6cc04f081db
|
|
BLAKE2b-256 checksum How to use checksums |
ce4855f48a736e6bca79224388f5931689baf0f4efdc30098d5cb336f772db7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Security for browser-use-turnstile 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.