tetrak_ocr.backends.claude

OCR a single image or PDF file using the Anthropic Claude vision API.

This module exposes the same interface as every other backend – SUPPORTED_EXTENSIONS and ocr_image(path) -> str – so that the registry, the batch pipeline and the evaluation harness can swap between them on a single command-line flag.

Requires:
  • An ANTHROPIC_API_KEY set in the environment or in a .env file.

  • pip install anthropic python-dotenv

Usage (standalone):

tetrak-ocr ocr workspace/scans/my-postcard.jpg –backend claude tetrak-ocr ocr workspace/scans/my-document.pdf –backend claude

Unlike the Tesseract backend, no local OCR engine is required and no preprocessing is performed — Claude interprets the file directly. PDFs are sent as base64-encoded document blocks (no conversion needed).

Functions

ocr_image(path)

Extract text from an image file using the Claude vision API.