Image OCR

$0.01 per call · USDC via x402 · POST /api/image-ocr

Extract text from an image (PNG/JPEG): returns the full text, overall confidence (0-100), and per-line bounding boxes. Send POST /api/image-ocr with no required fields (3 optional) and pay $0.01 per call over x402 or MPP (there is no free tier). It returns a JSON object with text, confidence, lang, lineCount, lines and 1 more.

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.

Category: Live public data · Tags: ocr image text-extraction tesseract scanned-document receipt extract text

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
imagestringnoBase64 PNG/JPEG (data: URL prefix accepted). Either this or url is required.
urlstringnoHTTPS URL to fetch the image from (max 8 MB). Either this or image is required.
langstringnoLanguage 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 request

curl -i -X POST https://agent402.tools/api/image-ocr \
  -H "Content-Type: application/json" \
  -d '{"url":"https://agent402.tools/fixtures/sample-text.png"}'

Without payment this returns HTTP 402 Payment Required with the exact price for image-ocr; any x402 v2 or MPP client pays it and retries.

Example response

{
  "text": "Agent402 sample text for OCR.\nInvoice 402-0001 total 12.34 USD.",
  "confidence": 94,
  "lang": "eng",
  "lineCount": 2,
  "lines": [
    {
      "text": "Agent402 sample text for OCR.",
      "confidence": 94.34,
      "bbox": {
        "x0": 24,
        "y0": 29,
        "x1": 469,
        "y1": 60
      }
    },
    {
      "text": "Invoice 402-0001 total 12.34 USD.",
      "confidence": 96.31,
      "bbox": {
        "x0": 27,
        "y0": 81,
        "x1": 514,
        "y1": 106
      }
    }
  ],
  "source": "tesseract.js (Tesseract WASM, Apache-2.0)"
}
FieldTypeAlways presentIn the example
textstringyesAgent402 sample text for OCR. Invoice 402-0001 total 12.34 USD.
confidencenumberyes94
langstringyeseng
lineCountnumberyes2
linesarray of objectsyes2 items in the example
sourcestringyestesseract.js (Tesseract WASM, Apache-2.0)

From an MCP client

catalog.call {
  "slug": "image-ocr",
  "params": {
    "url": "https://agent402.tools/fixtures/sample-text.png"
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for image-ocr; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.

Errors and behavior

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();
client.setSpendControls?.(false); // keep your own spending ceiling in code
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://agent402.tools/fixtures/sample-text.png"
  }),
});

Part of these workflows

Image OCR is one step in these 3 skill packs, each sold as a single call:

Related tools

A2A Agent Card validate

FREE w/ compute · or $0.002 · POST /api/a2a-card-validate

Validate an A2A (Agent2Agent protocol) Agent Card: required fields, skill shape, transport names, capability flags - spe…

Amortization schedule

FREE w/ compute · or $0.001 · POST /api/amortization

Build the full per-period amortization schedule for a fully-amortizing loan. Each row reports the period number, payment…

Annuity present/future value

FREE w/ compute · or $0.001 · POST /api/annuity

Present and future value of a level annuity (equal periodic payments). Supports an ordinary annuity (payments at period …

Barcode / QR decode

FREE w/ compute · or $0.001 · POST /api/barcode-decode

Decode a barcode or QR code from an image. Send a base64 PNG or JPEG (or a data: URL); returns the decoded text and the …

Barcode product lookup

$0.005 · GET /api/barcode-lookup

Look up a product by its UPC/EAN barcode number via Open Food Facts (open data): name, brand, category, quantity, and nu…

Black-Scholes option price

FREE w/ compute · or $0.002 · POST /api/black-scholes

Price a European option (call or put) with the Black-Scholes-Merton model, plus the greeks (delta, gamma, vega, theta, r…