API Tutorials

Case-Sensitive CAPTCHA API Parameter Guide

Some CAPTCHAs require exact case matching — AbCd is not abcd. Using the regsense parameter correctly prevents rejection of valid solves.


The regsense Parameter

Value Meaning
0 (default) Case-insensitive — solver may return any case
1 Case-sensitive — solver preserves original case

When Case Sensitivity Matters

Sites that validate case check the solve result exactly. If the CAPTCHA shows AbCd3F and you submit abcd3f, it fails.

Common case-sensitive sites:

  • Financial services login pages
  • Government portals
  • Some forum registrations
  • Custom CAPTCHA implementations

Basic Usage

import requests
import base64
import time
import os

API_KEY = os.environ["CAPTCHAAI_API_KEY"]


def solve_case_sensitive(image_b64):
    """Solve with case preservation."""
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "base64",
        "body": image_b64,
        "regsense": 1,    # Preserve case
        "json": 1,
    }, timeout=30)

    result = resp.json()
    if result.get("status") != 1:
        raise RuntimeError(result.get("request"))

    task_id = result["request"]

    time.sleep(8)
    for _ in range(24):
        resp = requests.get("https://ocr.captchaai.com/res.php", params={
            "key": API_KEY, "action": "get",
            "id": task_id, "json": 1,
        }, timeout=15)
        data = resp.json()
        if data.get("status") == 1:
            return data["request"]
        if data["request"] != "CAPCHA_NOT_READY":
            raise RuntimeError(data["request"])
        time.sleep(5)

    raise TimeoutError("Solve timeout")

Detecting Case Sensitivity

Before setting regsense, determine if the site requires it:

# detect_case.py


def detect_case_sensitivity(page_html):
    """Detect if CAPTCHA is likely case-sensitive."""
    indicators = [
        "case sensitive",
        "case-sensitive",
        "CaSe SeNsItIvE",
        "exact characters",
        "enter exactly",
    ]

    lower = page_html.lower()
    for indicator in indicators:
        if indicator.lower() in lower:
            return True

    return False


def detect_from_input(page_html):
    """Check input field attributes for clues."""
    import re

    # autocomplete="off" + no text-transform often means case-sensitive
    if 'autocomplete="off"' in page_html:
        return True

    # text-transform: uppercase means the site lowercases anyway
    if "text-transform: uppercase" in page_html:
        return False  # Not case-sensitive

    return None  # Unknown

Testing Case Sensitivity

# test_case.py


def test_case_sensitivity(solve_func, test_url):
    """Test whether a site validates case by submitting both."""
    # This requires two solves — use on first integration only

    # Solve 1: Case-sensitive
    result_sensitive = solve_func(regsense=1)

    # Solve 2: Lowercased
    result_lower = result_sensitive.lower()

    # If lowercased works, case doesn't matter
    # If only original works, case matters

    return {
        "original": result_sensitive,
        "lowered": result_lower,
        "needs_regsense": result_sensitive != result_lower,
    }

Combined with Other Parameters

# Case-sensitive, letters only, Latin, fixed length
params = {
    "regsense": 1,
    "numeric": 2,      # Letters only (no digits)
    "language": 2,     # Latin alphabet
    "minLen": 6,
    "maxLen": 6,
}

# Case-sensitive, mixed alphanumeric
params = {
    "regsense": 1,
    "minLen": 5,
    "maxLen": 8,
}

Common Mistakes

Mistake 1: Using regsense when not needed

# If the site lowercases input anyway, regsense=1 reduces accuracy
# Only set regsense=1 when the site actually checks case

Mistake 2: Not handling the response correctly

# WRONG — stripping case after solve
answer = solve_case_sensitive(image_b64).lower()  # Defeats the purpose

# RIGHT — use as-is
answer = solve_case_sensitive(image_b64)

Mistake 3: Mixing with numeric=1

# numeric=1 means digits only — no letters to be case-sensitive about
# Don't combine regsense=1 with numeric=1 (it's contradictory)

Troubleshooting

Issue Cause Fix
Answer rejected despite correct characters Case mismatch Enable regsense=1
Lower accuracy with regsense More ambiguous characters Add textinstructions for context
Always returns uppercase Image only has uppercase Set regsense=1 and textinstructions="all uppercase"
Some chars wrong case Ambiguous glyphs (o/O, s/S) Report bad answers for quality improvement

FAQ

Does regsense affect cost?

No. The parameter is free — it only guides the solver's output format.

Should I always use regsense=1?

No. Only use it when the target site validates case. Using it unnecessarily can reduce accuracy because the solver has to make harder decisions about ambiguous characters.

What about mixed case (some upper, some lower)?

Set regsense=1. The solver will attempt to match the exact case shown in the image.



Get the case right — start with CaptchaAI.

Full Working Code

Complete runnable examples for this article in Python, Node.js, PHP, Go, Java, C#, Ruby, Rust, Kotlin & Bash.

View on GitHub →

Discussions (0)

No comments yet.