Skip to content

docgate

Spend the minimum on document AI, and know exactly what you did not check.

docgate is a Python library for provider-neutral document extraction. It reads free, embedded text first; renders only pages that need a model; and returns a receipt alongside every result. It is a control layer around OCR and vision providers, not an OCR service or a document-understanding product.

import docgate

result = docgate.read("bundle.pdf")
print(result.text)
print(result.receipt.complete)
print(result.receipt.unknown)

What makes it different

  • Plan locally. plan() inspects a document without provider calls, network access, or credential use.
  • Spend deliberately. Selection policies, page quotes, a hard budget, and cache hits keep paid work visible and bounded.
  • Keep unread pages explicit. A page that was skipped, could not be rendered, or exhausted its provider ladder is an Unknown, never an empty string pretending to be a result.
  • Keep providers interchangeable. Use a native adapter, reuse the OpenAI-compatible route across conforming vision hosts, or wrap any local, private, or specialist engine with CallableProvider.
  • Keep operations auditable. The receipt records quotes, spend, cached pages, clamps, provider degradations, and unknown pages.

The processing model

  1. plan() reads local signals and creates a DocPlan.
  2. execute() reads usable text layers directly and sends other selected PDF pages to providers in order.
  3. read() is the convenience wrapper that performs both steps.

For scanned or image-only PDF pages, docgate rasterizes to PNG with a bounded pixel count before invoking a provider. For local formats such as DOCX and XLSX, it reads text locally and does not route content to a model.

Start here