API Tutorials

Improving OCR CAPTCHA Accuracy with CaptchaAI Settings

CaptchaAI provides parameters that tell the solver what to expect in an image CAPTCHA. Using these correctly can push accuracy beyond default levels.


Key Accuracy Parameters

Parameter Type Description
numeric 0/1/2 0 = no preference, 1 = numbers only, 2 = letters only
minLen int Minimum expected text length
maxLen int Maximum expected text length
regsense 0/1 1 = case-sensitive answer required
language int Language code (0 = not specified, 1 = Cyrillic, 2 = Latin)
textinstructions string Human-readable instructions for the solver
calc 0/1 1 = CAPTCHA contains a math equation

Numeric-Only CAPTCHAs

When the CAPTCHA only contains digits:

import requests
import os

API_KEY = os.environ["CAPTCHAAI_API_KEY"]


def solve_numeric_captcha(image_b64):
    """Solve a CAPTCHA that contains only numbers."""
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "base64",
        "body": image_b64,
        "numeric": 1,     # Numbers only
        "minLen": 4,       # At least 4 digits
        "maxLen": 6,       # At most 6 digits
        "json": 1,
    }, timeout=30)
    return resp.json()


# Without numeric=1, solver might read "0" as "O" or "1" as "l"
# With numeric=1, these ambiguities are eliminated

Letters-Only CAPTCHAs

def solve_letters_only(image_b64):
    """Solve when CAPTCHA contains only letters."""
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "base64",
        "body": image_b64,
        "numeric": 2,      # Letters only — no digits
        "regsense": 1,     # Case-sensitive
        "language": 2,     # Latin alphabet
        "json": 1,
    }, timeout=30)
    return resp.json()

Case Sensitivity

def solve_case_sensitive(image_b64):
    """Solve when the site validates case."""
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "base64",
        "body": image_b64,
        "regsense": 1,    # Must preserve case
        "json": 1,
    }, timeout=30)
    return resp.json()

# Default (regsense=0): "AbCd" might return as "abcd"
# With regsense=1: "AbCd" returns as "AbCd"

Length Constraints

Setting min/max length eliminates impossible answers:

def solve_fixed_length(image_b64, length=6):
    """Solve when CAPTCHA text is always a fixed length."""
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "base64",
        "body": image_b64,
        "minLen": length,
        "maxLen": length,  # Same value = exact length
        "json": 1,
    }, timeout=30)
    return resp.json()

Text Instructions

For complex CAPTCHAs, provide natural language hints:

def solve_with_instructions(image_b64, instructions):
    """Provide text instructions to guide the solver."""
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "base64",
        "body": image_b64,
        "textinstructions": instructions,
        "json": 1,
    }, timeout=30)
    return resp.json()


# Examples of helpful instructions:
solve_with_instructions(b64, "Enter only the red characters")
solve_with_instructions(b64, "Type the 4-digit number shown")
solve_with_instructions(b64, "Enter the characters ignoring strikethrough lines")
solve_with_instructions(b64, "Solve the math equation and enter the result")

Language-Specific CAPTCHAs

# Language codes:
# 0 = not specified (default)
# 1 = Cyrillic (Russian, Ukrainian, etc.)
# 2 = Latin (English, French, etc.)

def solve_cyrillic(image_b64):
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "base64",
        "body": image_b64,
        "language": 1,     # Cyrillic
        "json": 1,
    }, timeout=30)
    return resp.json()

Parameter Combination Patterns

Bank Security Code (6 digits)

params = {
    "numeric": 1,
    "minLen": 6,
    "maxLen": 6,
}

Forum Registration (mixed, case-sensitive, Latin)

params = {
    "regsense": 1,
    "language": 2,
    "minLen": 5,
    "maxLen": 8,
}

Math CAPTCHA

params = {
    "calc": 1,
    "textinstructions": "Solve the math expression",
}

Russian Text CAPTCHA

params = {
    "language": 1,
    "regsense": 0,
    "minLen": 4,
    "maxLen": 7,
}

Smart Parameter Detection

# auto_params.py

def detect_captcha_hints(page_html):
    """Auto-detect CAPTCHA parameters from the page."""
    hints = {}

    lower = page_html.lower()

    # Detect numeric hints
    if "digits" in lower or "numbers only" in lower:
        hints["numeric"] = 1
    elif "letters only" in lower:
        hints["numeric"] = 2

    # Detect length from input field
    import re
    maxlength = re.search(r'maxlength="(\d+)"', page_html)
    if maxlength:
        hints["maxLen"] = int(maxlength.group(1))

    # Detect case sensitivity
    if "case sensitive" in lower or "case-sensitive" in lower:
        hints["regsense"] = 1

    # Detect math
    if "solve" in lower and ("+" in page_html or "×" in page_html):
        hints["calc"] = 1

    return hints

Troubleshooting

Issue Cause Fix
Returns letters when only digits exist Missing numeric=1 Set numeric=1 for digit-only CAPTCHAs
Wrong case Missing regsense=1 Enable case sensitivity
Extra/fewer characters No length constraint Set minLen and maxLen
Wrong language characters Missing language Set language=1 (Cyrillic) or language=2 (Latin)
Math result wrong Missing calc=1 Enable calc mode for math CAPTCHAs

FAQ

Do these parameters cost extra?

No. All OCR parameters are included in the standard image CAPTCHA price.

What if I set wrong hints?

The solver may return lower-quality results. Only set parameters you're confident about. When in doubt, omit optional parameters.

Can I combine all parameters?

Yes. Use as many as apply simultaneously — numeric, regsense, minLen, maxLen, language, and textinstructions all work together.



Maximize OCR accuracy — 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.