Image OCR
POST /api/image-ocrExtract text from an image (PNG/JPEG): returns the full text, overall confidence (0-100), and per-line bounding boxes. Send either {image: base64} or {url: 'https://…'}. Pure-CPU Tesseract via tesseract.js - no upstream API, no keys. Default lang 'eng'; pass 'lang' (ISO 639-2) for others.
Input
| Field | Type | Description |
|---|---|---|
image | string | Base64 PNG/JPEG (data: URL prefix accepted). Either this or url is required. |
url | string | HTTPS URL to fetch the image from (max 8 MB). Either this or image is required. |
lang | string | Language code, ISO 639-2. Default 'eng'. Supported: eng, spa, fra, deu, ita, por, nld, rus, pol, tur, chi_sim, chi_tra, jpn, kor, ara, hin, tha, vie, ukr, ell. |
Example output
{
"text": "Mild Splendour of the various-vested Night!\nMother of wildly-working visions! hail!",
"confidence": 91.8,
"lang": "eng",
"lineCount": 2,
"lines": [
{
"text": "Mild Splendour of the various-vested Night!",
"confidence": 92.1,
"bbox": {
"x0": 24,
"y0": 12,
"x1": 658,
"y1": 48
}
},
{
"text": "Mother of wildly-working visions! hail!",
"confidence": 91.5,
"bbox": {
"x0": 24,
"y0": 56,
"x1": 612,
"y1": 92
}
}
],
"source": "tesseract.js (Tesseract WASM, Apache-2.0)"
}
Try it - see the 402 challenge (free)
curl -i -X POST https://agent402.tools/api/image-ocr \
-H "Content-Type: application/json" \
-d '{"url":"https://tesseract.projectnaptha.com/img/eng_bw.png"}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/image-ocr", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"url": "https://tesseract.projectnaptha.com/img/eng_bw.png"
}),
});
Part of these workflows
This tool is one step in 3 curated multi-tool workflows - agents can fetch the whole sequence as an MCP prompt or call https://agent402.tools/api/skill-packs/{slug}/prompt.
- Content extraction - Turn arbitrary URLs and PDFs into clean structured text - articles, page metadata, PDF pages, OCR'd images, browser-rendered SPAs.
- Document intelligence - Turn any PDF or image URL into structured data - metadata, extracted text, sliced page ranges, OCR for scanned docs, decoded barcodes / QR codes - without falling back to a vision LLM guess. Built for the messy 30% of documents where pdf-to-markdown alone returns nothing useful.
- Convert anything to markdown - Convert anything at a URL - HTML, PDF, or an image - to clean markdown. The 'I have a URL but it might be any content-type, give me markdown either way' workflow: HEAD-detect the content-type, branch to the right deterministic extractor (article extract for HTML, pdf-to-markdown for PDFs, OCR for images), and report token/word stats on the output so the caller can budget the result against an LLM context window.
Related tools
US gov dataset search
GET /api/gov-dataSearch 300,000+ US government datasets on catalog.data.gov (CKAN): titles, publishing org, formats, and direct resource …
US weather alerts
GET /api/weather-alertsActive National Weather Service alerts for a US state as clean JSON: event, severity, headline, affected areas, onset/ex…
Recent earthquakes (USGS)
GET /api/earthquakesReal-time USGS earthquake feed: magnitude, place, time, depth, coordinates. Live government data, no key. ?minMag=4.5&pe…