CaptchaNo
[ AGENTS ]

Captcha solving for
CrewAI agents

An agent that meets a challenge has nothing in its toolset that can answer it, so it stalls or hallucinates its way around. Give it a solver as a tool and the block becomes one more call.

python · crewai
import time
import requests

CAPTCHANO_KEY = "cn-YOUR_API_KEY"
HEADERS = {"Authorization": f"Bearer {CAPTCHANO_KEY}"}

def solve(task: dict) -> dict:
    """Block until solved; returns e.g. {"token": "...", "userAgent": "..."}."""
    r = requests.post(
        "https://api.captchano.com/v1/solve",
        params={"wait": 60},
        json=task,
        headers=HEADERS,
        timeout=75,
    )
    data = r.json()
    # A solve can outlast the 60 s wait: poll the task until it finishes.
    while data.get("status") in ("queued", "solving"):
        time.sleep(5)
        data = requests.get(
            f"https://api.captchano.com/v1/task/{data['id']}",
            headers=HEADERS,
            timeout=30,
        ).json()
    if data.get("status") != "ready":
        raise RuntimeError(data.get("error") or data)
    return data["solution"]

from crewai import Agent
from crewai.tools import tool

@tool("Solve captcha")
def solve_captcha(kind: str, sitekey: str, url: str) -> str:
    """Call when a captcha blocks the task. Returns the token to submit."""
    return solve({"type": kind, "sitekey": sitekey, "url": url})["token"]

researcher = Agent(role="Researcher", goal="...", backstory="...", tools=[solve_captcha])

Why agents need this specifically

A scraper that hits a challenge fails loudly and you fix it. An agent fails quietly: it reasons about the blocked page, invents a plausible next step, and reports progress it never made. The failure is worse because it is silent. A typed solver tool turns an ambiguous dead end into a deterministic result the agent can branch on.

What the tool returns

  • A token or cookie — depending on the challenge type. Session-graded systems return a cookie plus the header set used to earn it.
  • The user agent used, so the agent can replay it on submission.
  • The cost of the solve, so an agent operating under a budget can account for it rather than spending blind.

Keeping the loop bounded

Give the agent a solve budget per run. Every response reports its cost, so a supervisor can cut the loop when spend passes a threshold rather than discovering it on the invoice. At $0.00598 per solve a typical agent run costs a few cents or less, but an unbounded retry loop is still an unbounded retry loop.

Keep the tool call blocking

The examples call ?wait=60, so the tool returns a finished token in a single step. That matters more for agents than for scripts: a tool that returns "still solving" forces the model to reason about polling, which it does badly. If you need a longer ceiling, raise wait up to 120 seconds. Request shapes for every challenge type are in the API reference.

[ HOW IT FITS ]

How the solve fits into CrewAI

In CrewAI the solver is a custom tool assigned to the agent that browses. Other agents in the crew never need to know about captchas.

  1. 01
    Subclass BaseTool

    Define name, description and an args schema, and call the API in _run.

  2. 02
    Assign it

    Give the tool only to the agent that does the browsing.

  3. 03
    Describe the trigger

    The description says to use it when a page shows a captcha.

  4. 04
    Return the token

    Return the token string or a short error.

Getting the token into the page

The tool returns the token to the browsing agent, which submits it with its own tools.

[ PITFALLS ]

Where integrations usually go wrong

Tool on every agent

Only the browsing agent needs it. Giving it to everyone invites unnecessary calls.

Caching

Tokens are single-use. Disable CrewAI's tool result caching for the solver.

[ FAQ ]

CrewAI captcha FAQ

Does CrewAI have a built-in captcha tool?

Not for solving. A custom tool of a few lines covers it and keeps the key under your control.

Can several agents share one key?

Yes, or create a key per crew in the dashboard so usage is reported separately.

Does it work with CrewAI Flows?

Yes. The tool is called by an agent, wherever that agent runs.

Why disable caching?

A cached result would return an old token, which the site rejects because tokens are single-use and expire in about two minutes.

[ READ NEXT ]

Guides that help

Ready to build?

Start with a free 7-day trial of the Hobby plan, then pay per successful solve or keep the plan as your traffic grows. Cancel before the trial ends and you pay nothing.

See our plans
Are you an AI agent? See setup options →