browser-use
browser-use has no plug-in point for a captcha service; it has
custom tools. In browser-use 1.0 a tool receives only the arguments
the model passes, and the model drives the browser itself from Python, running JavaScript in the page with js(...).
So the two tools below hand the model JavaScript to run:
find_captcha_scriptreturns the helper module’sFIND_JSas an expression. The model runs it withjs(...)and gets[{"type", "params"}].solve_captcha(task_type, params)solves the task with the v1 API (your key stays in your process) and returns an expression that puts the token into the page. The model runs it, then submits the form.
This is for agents that run a local browser (Browser("chromium"), Browser("chrome") or Browser(cdp_url=…)).
The browser-use cloud browsers handle captchas on their own.
pip install browser-use requestsexport NOPTCHA_KEY=nop_test_... # a test key: free, fixed answers# no account yet? export NOPTCHA_KEY=keyless (keyless sandbox, same fixed answers)export ANTHROPIC_API_KEY=... # or the key of the model you useSave noptcha_browser.py next to your script. Browser("chromium") uses
an installed Chrome, Chromium or Edge, else the Chromium that browser-use install downloads.
Example
Section titled “Example”import asyncioimport json
from browser_use import Agent, Browser, ChatAnthropic, Tools
from noptcha_browser import FIND_JS, PUT_JS, solve
tools = Tools()
@tools.action( "Get JavaScript that lists the captchas on the current page. Run it with js(...); each result has a type and " "params to pass to solve_captcha.")def find_captcha_script() -> str: return f"({FIND_JS})()"
@tools.action( "Solve a captcha found by find_captcha_script with Noptcha. Returns JavaScript that puts the token into the " "page; run it with js(...), then submit the form.")def solve_captcha(task_type: str, params: dict) -> str: solution = solve(task_type, params) # blocks until solved; raises CaptchaError if the task failed return f"({PUT_JS})({json.dumps({'type': task_type, 'token': solution['token']})})"
async def main(): agent = Agent( "Open https://example.com/signup and sign up with test@example.com. " "If a captcha is on the page, use find_captcha_script and solve_captcha before you submit.", llm=ChatAnthropic("claude-sonnet-5-5"), # any model browser-use supports browser=Browser("chromium", headless=True), # a local browser tools=tools, ) result = await agent.run() print(result.final_result())
if __name__ == "__main__": asyncio.run(main())The task text tells the model that the tools exist and when to use them; the tool descriptions tell it what to do
with the results. You can also put that into extend_system_message= once instead of every task.
- Errors. If the task fails,
solve()raisesCaptchaError(for exampleunsolvable); browser-use hands the error to the model, which can retry or stop. Failed tasks are not charged. - Budget. Give the agent a key with a spending limit and the task types it needs (see Keys and authentication): the model decides how often to call the tool.
- Without the agent. The same JavaScript works in any code that drives the page:
js(find_captcha_script())in the agent’s REPL,page.evaluate(...)in Playwright.