How to integrate DeathByCaptcha into RAG pipelines

How to integrate DeathByCaptcha into RAG pipelines

Posted on 2026-11-24 | 4 min read | Category: web-scraping-guide | By DeathByCaptcha Engineering Team

Web Scraping Guide


How to integrate DeathByCaptcha into RAG pipelines

A RAG pipeline is only as good as the corpus behind it. The model can be perfect and the embeddings fresh, but if the crawl that feeds the index was stopped by a Cloudflare Turnstile on a Friday night, the retrieval will quietly answer from a corpus that is missing the pages you care about.

That is the argument for treating CAPTCHA solving as part of ingestion infrastructure, the same way you treat retries, rate limits and backoff.

Where the challenge shows up in a pipeline

Most RAG systems start by fetching documents: sitemaps, feeds, product pages, documentation, forum threads. The fetch stage meets the same defences any scraper meets:

  • a 403 or 429 with a Cloudflare Turnstile or an Amazon WAF challenge;
  • a login or registration form guarded by reCAPTCHA;
  • a DataDome interstitial in front of the document;
  • an image CAPTCHA on a form that gates the data.

Every one of those events ends the document's path to your index if the pipeline does nothing. The failure is silent: no exception reaches the embedding step, and the index simply has one fewer document.

source → fetch → challenge? ─yes→ DeathByCaptcha → token or cookie
                  │                        │
                  no                       ↓
                  ↓                   retry fetch
                document ──────────────────┘
                     ↓
        parse → chunk → embed → index

The integration point: the fetch, before the parse

Solving belongs in the transport layer of your ingestion code, not in the model. Three shapes cover most stacks:

1. Requests-based or Scrapy ingestion. The downloader middleware intercepts the challenge, sends it to DeathByCaptcha and retries the request with the cookie or header the site expects. This is the example shipped in the Node and Python clients (examples/scrapy/), and it works without a browser for the cookie-based types: Amazon WAF, DataDome and Turnstile where a cookie is what is validated.

2. Browser-based ingestion. When the pipeline drives a real page with Playwright or Puppeteer, the token types are what you need: reCAPTCHA v2 and v3, Turnstile and WAF. The samples in those repositories extract the sitekey, request the token, inject it and continue; the crawl then keeps its session and cookies.

3. Orchestrated pipelines. If your ingestion runs in n8n or in an agent, the same API is a single step: the n8n workflow example solves the challenge and passes the token to the next node, and an agent can call it as a tool. The pattern does not change, only the orchestrator.

A minimal sketch

def fetch_document(url, session):
    response = session.get(url, timeout=30)
    if not is_challenge(response):
        return response

    solution = client.decode(
        type=16,
        waf_params=json.dumps({
            "sitekey": extract_sitekey(response.text),
            "pageurl": url,
            "proxy": proxy,          # same exit IP as the crawler
            "proxytype": "HTTP",
        }),
    )
    if not solution:
        return None                # mark the document as missing, never fake it

    session.cookies.set("aws-waf-token", solution["text"])
    return session.get(url, timeout=30)

Two rules in that sketch are not optional: the proxy keeps the crawler and DeathByCaptcha on the same exit IP for the token types that are bound to it, and a failure returns None so the document is recorded as missing instead of being indexed from a partial parse.

Operational rules

  • Budget per run. Decide how many solves a crawl may spend before it stops and pages an operator. At $0.00289 per token solve, a thousand challenges cost about $2.89; that is cheap, an unbounded loop is not.
  • Retry caps. Two attempts, then the document goes to the "missing" bucket with its URL, status and captcha id.
  • Log the captcha id, never the token. The id is enough to report or refund a bad solve; the token is single-use and meaningless to logs.
  • Respect the source. Rate limits, robots rules and the terms of the site still apply: solving a challenge is not permission to hammer a server.
  • Keep the corpus honest. A document you could not fetch is missing data. Mark it, retry it on the next refresh, and never index a placeholder as if it were content.

Why this belongs in the retrieval budget

The cost of a solve is small compared with the cost of answering from an incomplete index: a wrong recommendation, a stale price, a policy answer that no longer exists on the source page. Scheduled re-crawls make it worse if every refresh quietly loses the same protected pages — the index looks healthy while a whole domain is absent.

Placing DeathByCaptcha at the fetch step turns an anti-bot wall into a measured, budgeted line item: the crawl either gets the document or records why it did not.

Next steps

  • Scrapy middleware example (Python client): https://github.com/deathbycaptcha/deathbycaptcha-api-client-python
  • Playwright and Puppeteer samples (Node client): https://github.com/deathbycaptcha/deathbycaptcha-api-client-nodejs
  • n8n workflow example: examples/n8n/ in the same repository.
  • Agent metadata for pipeline tooling: https://github.com/deathbycaptcha/deathbycaptcha-agent-api-metadata
  • API documentation: https://deathbycaptcha.com/api

If your pipeline already retries, solves nothing and drops the page on failure, the change is one branch in the fetch function and a budget in the settings.

Common pitfalls

  • Using a CAPTCHA solving service for illegitimate purposes instead of legitimate automation and testing.
  • Hard-coding credentials or API keys in client-side code that users can inspect.
  • Sending the wrong CAPTCHA type parameter, which returns incorrect or empty responses.
  • Failing to poll for the solution status and not handling timeouts gracefully.
  • Scaling automation without monitoring error rates, response times, and CAPTCHA type coverage.
DBC
Written by DeathByCaptcha Engineering Team
DeathByCaptcha engineers build and operate the CAPTCHA solving technology behind this site. Articles are written by our technical team and checked for accuracy before publishing.
Reviewed by DeathByCaptcha Editorial Team

Get your API key — start solving

Free to try · No credit card · Python, Node.js, Java, C# SDKs

Get your API key


Status: OK

Servers are fully operational with faster than average response time.
  • Average solving time
  • -- seconds - Normal CAPTCHAs (1 min. ago)
  • 6 seconds - reCAPTCHA V2, V3 (1 min. ago)
  • 6 seconds - others (1 min. ago)
Chrome and Firefox logos
Browser extensions available

Updates

  1. Nov 19: RESOLVED - Crypto payments are now fully operational again through the Hekelet payment processor.
  2. May 13: Crypto payments got better! You can now purchase your CAPTCHAs using cryptocurrency through the Hekelet payment processor at https://deathbycaptcha.com/user-pay and receive an extra 20% FREE CAPTCHA credit with every package purchased this way.
  3. Apr 15: GitHub Updates: We’ve upgraded our libraries, expanded sample code, enhanced documentation, and added support for C++ and Go, making integration smoother than ever. Explore what’s new at github.com/deathbycaptcha!

  4. Previous updates…

Support

Our system is designed to be completely user-friendly and easy-to-use. Should you have any trouble with it, simply email us at DBC technical support emailcom, and a support agent will get back to you as soon as possible.

Live Support

Available Monday to Friday (10am to 4pm EST) Live support image. Link to live support page