API Tutorials

Image CAPTCHA Solving Using API

Image CAPTCHAs (also called normal CAPTCHAs or text CAPTCHAs) show distorted text that users must type. Despite being the oldest CAPTCHA format, they are still used on many legacy systems, government portals, and registration forms.

CaptchaAI solves these by accepting the image and returning the recognized text.


Requirements

Item Value
CaptchaAI API key From captchaai.com
CAPTCHA image File or base64
Language Python 3.7+ or Node.js 14+

Step 1: Capture the CAPTCHA image

Screenshot method (Selenium)

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://example.com/register")

captcha_el = driver.find_element(By.CSS_SELECTOR, "#captcha-image")
captcha_el.screenshot("captcha.png")

Download from URL

import requests
import base64

img_url = "https://example.com/captcha/generate"
img_data = requests.get(img_url).content

# Save to file
with open("captcha.png", "wb") as f:
    f.write(img_data)

# Or convert to base64
img_b64 = base64.b64encode(img_data).decode()

Step 2: Submit to CaptchaAI

Method A: File upload (Python)

import requests
import time

API_KEY = "YOUR_API_KEY"

with open("captcha.png", "rb") as f:
    response = requests.post("https://ocr.captchaai.com/in.php",
        data={"key": API_KEY, "method": "post", "json": 1},
        files={"file": ("captcha.png", f, "image/png")}
    )

data = response.json()
task_id = data["request"]
print(f"Task: {task_id}")

Method B: Base64 (Python)

response = requests.post("https://ocr.captchaai.com/in.php", data={
    "key": API_KEY,
    "method": "base64",
    "body": img_b64,
    "json": 1
})

task_id = response.json()["request"]

Node.js (base64)

const axios = require('axios');
const fs = require('fs');

async function submitImageCaptcha(imagePath) {
  const imageB64 = fs.readFileSync(imagePath).toString('base64');

  const { data } = await axios.post('https://ocr.captchaai.com/in.php', null, {
    params: {
      key: 'YOUR_API_KEY',
      method: 'base64',
      body: imageB64,
      json: 1
    }
  });

  return data.request;
}

Step 3: Poll for the text result

def get_text_solution(task_id):
    for _ in range(30):
        time.sleep(5)
        result = requests.get("https://ocr.captchaai.com/res.php", params={
            "key": API_KEY, "action": "get", "id": task_id, "json": 1
        }).json()

        if result.get("status") == 1:
            return result["request"]  # The recognized text
        if result.get("request") != "CAPCHA_NOT_READY":
            raise Exception(f"Error: {result['request']}")

    raise Exception("Timeout")

text = get_text_solution(task_id)
print(f"CAPTCHA text: {text}")
async function getSolution(taskId) {
  for (let i = 0; i < 30; i++) {
    await new Promise(r => setTimeout(r, 5000));
    const { data } = await axios.get('https://ocr.captchaai.com/res.php', {
      params: { key: 'YOUR_API_KEY', action: 'get', id: taskId, json: 1 }
    });
    if (data.status === 1) return data.request;
    if (data.request !== 'CAPCHA_NOT_READY') throw new Error(data.request);
  }
  throw new Error('Timeout');
}

Step 4: Submit the text to the form

# Type the solved text into the CAPTCHA input
captcha_input = driver.find_element(By.CSS_SELECTOR, "#captcha-input")
captcha_input.clear()
captcha_input.send_keys(text)

# Submit the form
driver.find_element(By.CSS_SELECTOR, "form").submit()

Optional parameters for better accuracy

Parameter Value Purpose
numeric 1 = digits only, 2 = letters only Limits character set
min_len Integer Minimum text length
max_len Integer Maximum text length
language 0 = any, 1 = Cyrillic, 2 = Latin Character language
calc 1 CAPTCHA is a math expression
phrase 1 CAPTCHA contains spaces
regsense 1 Case-sensitive
response = requests.post("https://ocr.captchaai.com/in.php", data={
    "key": API_KEY,
    "method": "base64",
    "body": img_b64,
    "numeric": 1,       # Digits only
    "min_len": 4,        # At least 4 characters
    "max_len": 6,        # At most 6 characters
    "json": 1
})

Complete Python example

import requests
import time
import base64
from selenium import webdriver
from selenium.webdriver.common.by import By

API_KEY = "YOUR_API_KEY"

# 1. Get the page and capture captcha
driver = webdriver.Chrome()
driver.get("https://example.com/register")

captcha_el = driver.find_element(By.CSS_SELECTOR, "#captcha-image")
captcha_el.screenshot("captcha.png")

# 2. Submit to CaptchaAI
with open("captcha.png", "rb") as f:
    img_b64 = base64.b64encode(f.read()).decode()

resp = requests.post("https://ocr.captchaai.com/in.php", data={
    "key": API_KEY, "method": "base64", "body": img_b64, "json": 1
}).json()
task_id = resp["request"]

# 3. Get solution
for _ in range(30):
    time.sleep(5)
    result = requests.get("https://ocr.captchaai.com/res.php", params={
        "key": API_KEY, "action": "get", "id": task_id, "json": 1
    }).json()
    if result.get("status") == 1:
        text = result["request"]
        break

# 4. Type and submit
driver.find_element(By.CSS_SELECTOR, "#captcha-input").send_keys(text)
driver.find_element(By.CSS_SELECTOR, "form").submit()
print(f"Solved: {text}")
driver.quit()

FAQ

How accurate is image CAPTCHA solving?

CaptchaAI achieves high accuracy for standard text CAPTCHAs. Using hint parameters (numeric, min_len, max_len) improves accuracy by constraining the character set.

How fast is image CAPTCHA solving?

Typically 5–15 seconds, faster than grid or interactive challenges.

Can I solve math CAPTCHAs?

Yes. Set calc=1 and the solver will compute the result (e.g., "3 + 7" returns "10").

What if the CAPTCHA text is case-sensitive?

Set regsense=1 to preserve letter case. Without this, the solver may return lowercase.

Can I report incorrect solutions?

Yes. Use https://ocr.captchaai.com/res.php?key=KEY&action=reportbad&id=TASK_ID to report an incorrect solution. This helps improve accuracy and may refund the solve cost.


Discussions (0)

No comments yet.

Related Posts

API Tutorials Solving CAPTCHAs with Swift and CaptchaAI API
Complete guide to solving re CAPTCHA, Turnstile, and image CAPTCHAs in Swift using Captcha AI's HTTP API with URLSession, async/await, and Alamofire.

Complete guide to solving re CAPTCHA, Turnstile, and image CAPTCHAs in Swift using Captcha AI's HTTP API with...

Automation Cloudflare Turnstile reCAPTCHA v2
Apr 05, 2026
Tutorials CAPTCHA Solving Fallback Chains
Implement fallback chains for CAPTCHA solving with Captcha AI.

Implement fallback chains for CAPTCHA solving with Captcha AI. Cascade through solver methods, proxy pools, an...

Python Automation Cloudflare Turnstile
Apr 06, 2026
Troubleshooting Common Grid Image CAPTCHA Errors and Fixes
Fix common grid image CAPTCHA solving errors.

Fix common grid image CAPTCHA solving errors. Covers image quality issues, wrong cell selection, timeout error...

Automation Image OCR Grid Image
Mar 29, 2026
API Tutorials Solve Image CAPTCHA with Node.js and CaptchaAI
Step-by-step Node.js tutorial for solving distorted text image CAPTCHAs using the Captcha AI OCR API.

Step-by-step Node.js tutorial for solving distorted text image CAPTCHAs using the Captcha AI OCR API. Includes...

Automation Image OCR Node.js
Mar 21, 2026
API Tutorials Batch Image CAPTCHA Solving: Processing 1000+ Images
Process thousands of image CAPTCHAs efficiently with Captcha AI using async queues, worker pools, and rate-aware batching in Python and Node.js.

Process thousands of image CAPTCHAs efficiently with Captcha AI using async queues, worker pools, and rate-awa...

Python Automation Image OCR
Mar 21, 2026
Tutorials Python Multiprocessing for Parallel CAPTCHA Solving
Use Python multiprocessing to solve CAPTCHAs in parallel with Captcha AI.

Use Python multiprocessing to solve CAPTCHAs in parallel with Captcha AI. Process Pool Executor, Pool, and hyb...

Python Automation Image OCR
Apr 01, 2026
Tutorials Image CAPTCHA Confidence Scores: Using CaptchaAI Quality Metrics
how to use Captcha AI's confidence indicators for image CAPTCHA solutions — assess answer quality, implement confidence-based retry logic, and optimize solve ra...

Learn how to use Captcha AI's confidence indicators for image CAPTCHA solutions — assess answer quality, imple...

Python Automation Image OCR
Mar 30, 2026
Comparisons Grid Image vs Normal Image CAPTCHA: API Parameter Differences
Compare Grid Image and Normal Image CAPTCHA types — different API parameters, response formats, and when to use each method with Captcha AI.

Compare Grid Image and Normal Image CAPTCHA types — different API parameters, response formats, and when to us...

Automation Image OCR Migration
Mar 25, 2026
API Tutorials Bash Script + cURL + CaptchaAI: Shell CAPTCHA Automation
Complete guide to solving re CAPTCHA, Turnstile, and image CAPTCHAs using Bash scripts and c URL with Captcha AI's HTTP API for shell-based automation.

Complete guide to solving re CAPTCHA, Turnstile, and image CAPTCHAs using Bash scripts and c URL with Captcha...

Automation Cloudflare Turnstile reCAPTCHA v2
Mar 20, 2026
API Tutorials Solving CAPTCHAs with Ruby and CaptchaAI API
Complete guide to solving re CAPTCHA, Turnstile, and image CAPTCHAs in Ruby using Captcha AI's HTTP API with net/http, Faraday, and HTTParty.

Complete guide to solving re CAPTCHA, Turnstile, and image CAPTCHAs in Ruby using Captcha AI's HTTP API with n...

Automation Cloudflare Turnstile reCAPTCHA v2
Mar 17, 2026
API Tutorials Case-Sensitive CAPTCHA API Parameter Guide
How to use the regsense parameter for case-sensitive CAPTCHA solving with Captcha AI.

How to use the regsense parameter for case-sensitive CAPTCHA solving with Captcha AI. Covers when to use, comm...

Python Web Scraping Image OCR
Apr 09, 2026
API Tutorials How to Solve reCAPTCHA v2 Enterprise with Python
Solve re CAPTCHA v 2 Enterprise using Python and Captcha AI API.

Solve re CAPTCHA v 2 Enterprise using Python and Captcha AI API. Complete guide with sitekey extraction, task...

Python Automation reCAPTCHA v2
Apr 08, 2026
API Tutorials Graceful Degradation When CAPTCHA Solving Fails
Keep your automation running when CAPTCHA solving fails — fallback strategies, queue-based retries, and degraded-mode patterns.

Keep your automation running when CAPTCHA solving fails — fallback strategies, queue-based retries, and degrad...

Python Automation All CAPTCHA Types
Apr 06, 2026