Skip to main content

crewai-turnstile

Give a CrewAI agent the ability to solve Cloudflare Turnstile. A BaseTool that takes a page URL and a sitekey, calls Peak, and hands back a token. A crew that browses the web and hits a Turnstile challenge gets a move to make instead of getting stuck.

Python 3.10+ crewai tool MIT License


A crew that browses the web eventually runs into Cloudflare Turnstile. The widget needs a token minted server-side. No fingerprint, proxy, or retry loop gets around that; it's a missing capability, not a detection problem. This package is that capability, packaged as a CrewAI BaseTool: give it a URL and a sitekey, it returns a token.

The tool itself never touches a browser. It is pure request/response to the Peak API, which keeps it usable from any crew regardless of whether its agents are driving Playwright, Selenium, a raw HTTP client, or nothing at all. Pair it with whatever tool your agent already uses to read the DOM (to get the sitekey) and to run JS (to put the token back); see Closing the loop below.

Install

pip install crewai-turnstile

Use it

from crewai_turnstile import PeakTurnstileTool

tool = PeakTurnstileTool(api_key="pk_...")  # or set PEAK_API_KEY
token = tool.run(url="https://example.com/login", sitekey="0x4AAAAAAA...")

Hand it to an agent like any other tool:

from crewai import Agent
from crewai_turnstile import PeakTurnstileTool

agent = Agent(
    role="Web researcher",
    goal="Fetch pages and clear any Turnstile challenge blocking them",
    backstory="You browse pages via tools and solve Turnstile when it blocks one.",
    tools=[*your_browser_tools, PeakTurnstileTool(api_key=api_key)],
)

The agent decides when to call it, typically after a browsing tool reports it's stuck on a Cloudflare challenge. The tool's description is written for that: an LLM reading the tool list will reach for solve_cloudflare_turnstile when it sees a Turnstile widget blocking a page.

Closing the loop

Reading the sitekey and injecting the token both happen on a live page, which is specific to whatever browser your crew drives, so this package deliberately doesn't pick one for you. inject.py ships the JS every other Peak wrapper package uses, so you can call it from whichever execute_script / page.evaluate your stack exposes:

from crewai_turnstile import build_injection_script

page.evaluate(build_injection_script(token))          # Playwright
driver.execute_script(build_injection_script(token))  # Selenium

It fills every cf-turnstile-response field and fires the widget's data-callback if the page registered one, the same two places a real form submit reads from.

Matching the exit IP

Turnstile scores the IP that submits the token. If your agent's browser runs behind a proxy, pass the same one so the token and the request line up:

tool.run(url=url, sitekey=sitekey, proxy="http://user:pass@host:port")

Leave proxy out and the tool solves through Peak's own IP pool instead. Fine for most sites, wrong for the ones that bind the token to the requesting IP.

Errors come back as text, not exceptions

A tool-calling agent works better when a failure is something it can read and react to, rather than a crash that kills the run. PeakTurnstileTool returns "ERROR: <reason>" (bad sitekey, no balance, no key configured) instead of raising, so the agent's next step can be "try a different sitekey" rather than "the whole crew run died." Call PeakClient.solve() directly from crewai_turnstile.peak if you want exceptions instead.

Getting a key

The tool needs an API key for the solver it calls: Peak. Turnstile solves come back in about a second. You pay $0.90 per 1,000 successful solves, down to $0.35 at volume, and only for the ones that land — failed solves are free. The free trial gives you roughly 1,000 solves to wire this up and test it end to end.

For Cloudflare Turnstile, Cloudflare 5s challenge, AWS WAF, and DataDome:
Peak
API-first · $0.35 – $0.90 / 1K · volume tiers · pay only on success · peak.fo

Same pattern for driving an agent framework directly: langchain-turnstile. For driving a browser without an agent on top: playwright-turnstile · selenium-turnstile · puppeteer-extra-plugin-turnstile · camoufox-turnstile.

Notes

Use this on sites and accounts you're 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 CrewAI Inc.

License

MIT

Metadata

Release files for crewai-turnstile 0.1.1

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

Source distribution (sdist)

Source distribution for crewai-turnstile 0.1.1
File Size Uploaded
crewai_turnstile-0.1.1.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crewai-turnstile 0.1.1
File Interpreter ABI Platform
crewai_turnstile-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.9 kB

Release files / crewai_turnstile-0.1.1.tar.gz

Download URL crewai_turnstile-0.1.1.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
26a1881c59ddf7926a20247af24cfe24eb4f7ca58ee7b7c4a645752b706bf2fd
BLAKE2b-256 checksum
How to use checksums
31998f55f5fdeb3217d8ec7d46849641f9c0d06072cd17aee33b6ecde923909e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / crewai_turnstile-0.1.1-py3-none-any.whl

Download URL crewai_turnstile-0.1.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8ff96701e933687cd1ecfabfeb2d9f46055a694963bf6f8e436371bae01c2e4
BLAKE2b-256 checksum
How to use checksums
7500b0a39be1ea2c9029e59727aec72221a94e2a20b92bd7099c5250a996191b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.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