NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

AI agents and automation

When a Browser Use agent gets blocked

Browser Use lets a model operate Chromium through Playwright, which also means it inherits every sign of automation a site can see. This guide sorts out which block you are facing and adds a custom action that hands CAPTCHAs to the API.

Diagnose the block before fixing it

Not every stop is a CAPTCHA. Before you add any solving code, look at what the agent actually received. Browser Use can save screenshots and a history of steps, and the final page of a failed run usually tells you which of four situations you are in.

What you seeLikely causeWhat helps
A checkbox or a Turnstile box inside the pageAn interactive widget on a formSolve the widget, fill the token
A full page "checking your browser" screenThe Cloudflare challenge page interstitialA cf_clearance cookie from the same IP
A small puzzle with a 405 statusAWS WAFAn aws-waf-token cookie
Plain 403 or "access denied" with no puzzleIP or rule blockNo CAPTCHA to solve; change network or slow down

The last row matters. If there is no challenge, there is nothing to solve, and a solver will not help. Spend that effort on the network and pacing instead; our guide to avoiding IP bans is a good start.

Why the model cannot click through on its own

Browser Use agents are good at forms and navigation, and they will happily click a reCAPTCHA checkbox. Sometimes it passes. More often the image grid appears and the model tries to pick tiles from a screenshot, which takes several slow steps and adds more automated looking activity. Turnstile and invisible reCAPTCHA have nothing useful to click at all. A dedicated action that returns a token is quicker and does not depend on the model's eyesight.

Add a custom solve action

Browser Use supports custom actions registered with a decorator. In recent releases the registry object is called Tools; older releases used Controller with the same .action decorator. The parameter that gives your function access to the live browser has also been renamed between versions, so check the custom actions page of the docs for your installed version. The sketch below keeps the browser part in one helper you adapt, and the API part is plain HTTP that does not change.

import asyncio, os
import httpx

GATE_HOST = "https://gatesolver.com"

async def gate_call(client: httpx.AsyncClient, route: str, data: dict) -> dict:
    data["clientKey"] = os.environ["GATESOLVER_KEY"]
    r = await client.post(f"{GATE_HOST}/{route}", json=data, timeout=30)
    return r.json()

async def token_for(task: dict) -> tuple[str | None, str]:
    async with httpx.AsyncClient() as client:
        opened = await gate_call(client, "createTask", {"task": task})
        if opened.get("errorId", 0) != 0:
            return None, opened.get("errorCode", "error")
        for _ in range(40):
            await asyncio.sleep(3)
            got = await gate_call(client, "getTaskResult", {"taskId": opened["taskId"]})
            if got.get("status") == "ready":  # done
                sol = got["solution"]
                return sol.get("gRecaptchaResponse") or sol.get("token"), "ready"
            if got.get("status") == "failed" or got.get("errorId"):
                return None, got.get("errorCode", "failed")
    return None, "timeout"

The function handles both reCAPTCHA (which returns gRecaptchaResponse) and Turnstile (which returns token), because those are the two widgets a browsing agent meets most often on forms.

The action itself

from browser_use import Tools  # older versions: from browser_use import Controller

tools = Tools()

@tools.action("Solve the CAPTCHA widget on the current page before submitting")
async def solve_page_captcha(browser_session) -> str:
    page = await current_page(browser_session)  # adapt to your version
    probe = await page.evaluate("""() => {
      const ts = document.querySelector('.cf-turnstile[data-sitekey]');
      if (ts) return {kind: 'ts', key: ts.dataset.sitekey};
      const rc = document.querySelector('.g-recaptcha[data-sitekey]');
      return rc ? {kind: 'rc', key: rc.dataset.sitekey} : null; }""")
    if not probe:
        return "No supported widget found on this page."
    task = ({"type": "AntiTurnstileTaskProxyLess"} if probe["kind"] == "ts"
             else {"type": "ReCaptchaV2TaskProxyLess"})
    task.update(websiteURL=page.url, websiteKey=probe["key"])
    answer, state = await token_for(task)
    if not answer:
        return f"Solve did not finish ({state}). Do not loop on this page."
    field = "cf-turnstile-response" if probe["kind"] == "ts" else "g-recaptcha-response"
    await page.evaluate("([n, v]) => document.querySelectorAll(`[name='${n}']`)"
                        ".forEach(e => e.value = v)", [field, answer])
    return "Widget solved and token placed. Submit the form next."

Pass the tools object to the Agent when you create it, next to the task and the model. The model sees the description string and calls the action when it meets a widget. The exact keyword for passing custom tools may differ between versions, so confirm it in your installed release.

Keep the session consistent

A token or cookie is accepted more reliably when everything around it matches. Three rules keep the session coherent after a solve.

  • Same browser profile. Do not open a new context for the submit. The site may have tied the challenge to cookies set on the first visit.
  • Same IP when the type needs it. The Cloudflare challenge page and DataDome return cookies that only work from the proxy used for the task. If you route the browser through a proxy, pass the same one to the task. Turnstile and reCAPTCHA proxyless tasks do not need this.
  • Same identity. Results include a userAgent. For cookie types, set the browser to that User-Agent, otherwise the site sees one browser earn the cookie and another one use it.

Handling full page challenges

For the Cloudflare interstitial, a form widget action is the wrong tool. Create an AntiCloudflareTask with the page URL and the same proxy your browser uses, then add the cf_clearance cookie to the browser context and reload. This is easier to do before the agent starts: open the target once in code, clear the check, then give the warmed up session to the agent. The guide on getting past the Cloudflare challenge in Python has the cookie handling.

Watching cost and attempts

Each successful solve is charged at the type's rate, for example $0.84 per 1,000 for Turnstile. Failures are free, but an agent that loops still wastes time. Keep a counter in the action keyed by page URL and return a "stop" message after two failures. Also set the agent's maximum step count so a confused run ends on its own.

Use agents like this on sites you own, test environments, or public pages whose terms allow automation. Logging into accounts that are not yours is outside our terms.

Prompting the agent to use the action

A custom action is only useful if the model picks it at the right time. Two sentences in the task text are usually enough: "If a page shows a CAPTCHA or security checkbox, call solve_page_captcha once before submitting. Never reload a page after that action succeeds." The first tells the model the action exists for this case; the second prevents the most common way of wasting a token. Keep the action description itself short and concrete, since Browser Use shows it to the model with every step.

Watch the first few runs with the browser visible. You should see the agent fill the form, call the action, pause for a few seconds while the task is solved, and then submit. If it clicks the checkbox first and only calls the action after that fails, move the sentence about the action higher in the task text.

Testing without a model in the loop

You can test token_for alone from an ordinary asyncio.run() call with a fixed URL and site key. That confirms the key, the network path and the task fields before any model cost is involved, and turns a vague "the agent fails" into a specific error code you can act on.

Common questions

Does Browser Use solve CAPTCHAs out of the box?

It can click simple widgets, but it has no token based solving. A custom action that calls an HTTP API adds that.

Why did my action stop working after upgrading Browser Use?

The registry and browser parameter names have changed between releases. Compare your action signature with the custom actions docs for the new version.

Does the agent need a proxy for Turnstile?

No. The Turnstile task is proxyless. Only cookie based types such as the Cloudflare challenge page need the same proxy as the browser.

Can I run several Browser Use agents with one API key?

Yes. There is no limit on concurrent tasks; keep total calls under 600 per minute per key.

What if the block is a plain 403 without a puzzle?

Then there is no CAPTCHA to solve. Slow the agent down, review the network it uses, and check whether the site allows automation.

Keep reading