
Last week the exception was AWS WAF: one call, and the token is already in the response. Image text is the call that article skipped. You hand over a picture, you wait, and you read a string.
This walkthrough uses Kaptra's captcha API and the ImageToTextTask type. It is the example in the introduction, and it is the lowest rate on the public price list.
Two fields, then you wait
ImageToTextTask is async. /createTask returns status=processing and a taskId. Poll /getTaskResult every 1 to 2 seconds, at most 120 times for that id. The introduction names AntiAwsWafTask as the type that skips this. Everything else, including this one, does not.
The task object has two required fields and no documented optional ones:
-
type:ImageToTextTask -
body: the image as base64. Adata:image/...;base64,prefix is allowed. The minimal request sends the raw string.
No site key, no page URL, no proxy. clientKey goes in the JSON body, not in an Authorization header. HTTP status is always 200. Read errorId (0 or 1) and errorCode.
What you get back
A ready task has one solution field, text. The documented example is abc123. There is no cookie to attach and no expiry to race. While the worker is busy, the result query returns CAPTCHA_NOT_READY. That is not a failure. Keep polling. After 120 queries on the same id you get ERROR_TOO_MANY_REQUESTS, and you stop.
Full Python example
import base64 import time from pathlib import Path import requests BASE_URL = "https://api.kaptra.ai" API_KEY = "YOUR_KAPTRA_API_KEY" def solve_image_text(image_path: str) -> str: body = base64.b64encode(Path(image_path).read_bytes()).decode() created = requests.post( f"{BASE_URL}/createTask", json={ "clientKey": API_KEY, "task": {"type": "ImageToTextTask", "body": body}, }, ).json() if created.get("errorId"): raise RuntimeError(f"createTask failed: {created.get('errorCode')}") task_id = created["taskId"] for _ in range(120): result = requests.post( f"{BASE_URL}/getTaskResult", json={"clientKey": API_KEY, "taskId": task_id}, ).json() if result.get("errorId") and result.get("errorCode") != "CAPTCHA_NOT_READY": raise RuntimeError(f"getTaskResult failed: {result.get('errorCode')}") if result.get("status") == "ready": return result["solution"]["text"] if result.get("status") == "failure": raise RuntimeError(f"task failed: {result.get('errorCode')}") time.sleep(1.5) raise TimeoutError("gave up after 120 polls") if __name__ == "__main__": print(solve_image_text("captcha.png")) What the docs do not say
No max size, no format list, no language list. Do not fill those in yourself. Invalid base64 is ERROR_BAD_REQUEST. An image the worker cannot read is ERROR_CAPTCHA_UNSOLVABLE. Do not resubmit that same image in a loop. Check the file, then create a new task.
This is also not AwsWafClassification. That type takes nine tiles and a question, and it returns tile indices. One image, one string: stay here.
The pricing page lists this type at under 10 seconds and $0.40 per 1,000 successful solves. Failed and timed-out tasks are not billed. There is no monthly fee and no minimum. ERROR_TASK_NOT_SUPPORTED means the type string is wrong or the type is disabled. ERROR_ZERO_BALANCE means stop and top up.
- Site: kaptra.ai
- ImageToTextTask docs: kaptra.ai/docs
Questions or a task type you would like covered next? The team answers tickets in Discord.