Skip to main content

Gemini OCR

gemini-ocr

Traceable Generative Markdown for PDFs

gemini-ocr provides anchorite provider plugins that convert PDFs to traceable Markdown using Google Cloud APIs.

  • GeminiMarkdownProvider — generates Markdown via the Gemini API
  • DocAIMarkdownProvider — generates Markdown via Document AI Layout
  • DocAIAnchorProvider — extracts bounding boxes via Document AI OCR
  • DoclingMarkdownProvider — generates Markdown via Docling (stub)

Quick Start

import asyncio
from pathlib import Path

import anchorite
from gemini_ocr import DocAIAnchorProvider, GeminiMarkdownProvider

async def main():
    markdown_provider = GeminiMarkdownProvider(
        project_id="my-gcp-project",
        location="us-central1",
        model_name="gemini-2.5-flash",
    )
    anchor_provider = DocAIAnchorProvider(
        project_id="my-gcp-project",
        location="us-central1",
        processor_id="projects/.../processors/...",
    )

    chunks = anchorite.document.chunks(Path("document.pdf"))
    result = await anchorite.process_document(
        chunks, markdown_provider, anchor_provider, renumber=True
    )

    print(result.markdown_content)
    print(result.annotate())   # Markdown with inline <span data-bbox="..."> tags

asyncio.run(main())

Configuration via Environment Variables

from_env() builds providers from environment variables, useful for twelve-factor deployments:

import anchorite
from gemini_ocr import from_env

markdown_provider, anchor_provider = from_env()
chunks = anchorite.document.chunks(Path("document.pdf"))
result = await anchorite.process_document(chunks, markdown_provider, anchor_provider)
Variable Description
GEMINI_OCR_PROJECT_ID GCP project ID (required)
GEMINI_OCR_LOCATION GCP location (default: us-central1)
GEMINI_OCR_MODE gemini (default), documentai, or docling
GEMINI_OCR_GEMINI_MODEL_NAME Gemini model name (required in gemini mode)
GEMINI_OCR_LAYOUT_PROCESSOR_ID Document AI processor ID (required in documentai mode)
GEMINI_OCR_OCR_PROCESSOR_ID Document AI OCR processor ID (enables bounding box extraction)
GEMINI_OCR_DOCUMENTAI_LOCATION Document AI endpoint location override
GEMINI_OCR_QUOTA_PROJECT_ID Quota project override for Gemini API calls
GEMINI_OCR_GEMINI_PROMPT Additional prompt appended to the default Gemini prompt
GEMINI_OCR_CACHE_DIR Directory for caching API responses
GEMINI_OCR_INCLUDE_BBOXES Set to false to skip bounding box extraction (default: true)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for gemini-ocr 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gemini-ocr 0.5.0
File Size Uploaded Provenance Actions
gemini_ocr-0.5.0.tar.gz 227.5 kB With provenance Details for gemini_ocr-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gemini-ocr 0.5.0
File Interpreter ABI Platform Actions
gemini_ocr-0.5.0-py3-none-any.whl Python 3 none any Details for gemini_ocr-0.5.0-py3-none-any.whl

Total release size: 238.4 kB

Release files / gemini_ocr-0.5.0.tar.gz

Download URL gemini_ocr-0.5.0.tar.gz
Size 227.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ba6e168c75d07b88c15ac65512d7371d5e74d32944914974451975e9a4610dca
BLAKE2b-256 checksum
How to use checksums
7db6ddbc47983e046ed3a0c699a7317c249689b4c38b55ff83b66aac8ef31deb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.

Transparency log

Release files / gemini_ocr-0.5.0-py3-none-any.whl

Download URL gemini_ocr-0.5.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5faf5189d2e3faf4374653ddc90e8de8823dbb20b9bbd227a8a4deb3887036d5
BLAKE2b-256 checksum
How to use checksums
c47178205457b7001b98be71431ed03108f23d01ac2b874b5d50f600c94b6eda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.

Transparency log

Security for gemini-ocr 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gemini_ocr-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page