Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
Z

zerox

> 编程语言
Open source

OCR & Document Extraction using vision models

12.3K stars0 likes1 views
WebsiteGitHub

About

OCR & Document Extraction using vision models

Zerox OCR

A dead simple way of OCR-ing a document for AI ingestion. Documents are meant to be a visual representation after all. With weird layouts, tables, charts, etc. The vision models just make sense!

The general logic:

  • Pass in a file (PDF, DOCX, image, etc.)
  • Convert that file into a series of images
  • Pass each image to GPT and ask nicely for Markdown
  • Aggregate the responses and return Markdown

Try out the hosted version here: https://getomni.ai/ocr-demo Or visit our full documentation at: https://docs.getomni.ai/zerox

Getting Started

Zerox is available as both a Node and Python package.

  • Node README - npm package
  • Python README - pip package
Feature Node.js Python
PDF Processing ✓ (requires graphicsmagick) ✓ (requires poppler)
Image Processing ✓ ✓
OpenAI Support ✓ ✓
Azure OpenAI Support ✓ ✓
AWS Bedrock Support ✓ ✓
Google Gemini Support ✓ ✓
Vertex AI Support ✗ ✓
Data Extraction ✓ (schema) ✗
Per-page Extraction ✓ (extractPerPage) ✗
Custom System Prompts ✗ ✓ (custom_system_prompt)
Maintain Format Option ✓ (maintainFormat) ✓ (maintain_format)
Async API ✓ ✓
Error Handling Modes ✓ (errorMode) ✗
Concurrent Processing ✓ (concurrency) ✓ (concurrency)
Temp Directory Management ✓ (tempDir) ✓ (temp_dir)
Page Selection ✓ (pagesToConvertAsImages) ✓ (select_pages)
Orientation Correction ✓ (correctOrientation) ✗
Edge Trimming ✓ (trimEdges) ✗

Node Zerox

(Node.js SDK - supports vision models from different providers like OpenAI, Azure OpenAI, Anthropic, AWS Bedrock, Google Gemini, etc.)

Installation

bash
npm install zerox

Zerox uses graphicsmagick and ghostscript for the PDF => image processing step. These should be pulled automatically, but you may need to manually install.

On linux use:

bash
sudo apt-get update
sudo apt-get install -y graphicsmagick

Usage

With file URL

typescript
import { zerox } from "zerox";

const result = await zerox({
  filePath: "https://omni-demo-data.s3.amazonaws.com/test/cs101.pdf",
  credentials: {
    apiKey: process.env.OPENAI_API_KEY,
  },
});

From local path

typescript
import { zerox } from "zerox";
import path from "path";

const result = await zerox({
  filePath: path.resolve(__dirname, "./cs101.pdf"),
  credentials: {
    apiKey: process.env.OPENAI_API_KEY,
  },
});

Parameters

…

The maintainFormat option tries to return the markdown in a consistent format by passing the output of a prior page in as additional context for the next page. This requires the requests to run synchronously, so it's a lot slower. But valuable if your documents have a lot of tabular data, or frequently have tables that cross pages.

Request #1 => page_1_image
Request #2 => page_1_markdown + page_2_image
Request #3 => page_2_markdown + page_3_image

Example Output

…

Data Extraction

Zerox supports structured data extraction from documents using a schema. This allows you to pull specific information from documents in a structured format instead of getting the full markdown conversion.

Set extractOnly: true and provide a schema to extract structured data. The schema follows the JSON Schema standard.

Use extractPerPage to extract data per page instead of from the whole document at once.

You can also set extractionModel, extractionModelProvider, and extractionCredentials to use a different model for extraction than OCR. By default, the same model is used.

Supported Models

Zerox supports a wide range of models across different providers:

  • Azure OpenAI

    • GPT-4 Vision (gpt-4o)
    • GPT-4 Vision Mini (gpt-4o-mini)
    • GPT-4.1 (gpt-4.1)
    • GPT-4.1 Mini (gpt-4.1-mini)
  • OpenAI

    • GPT-4 Vision (gpt-4o)
    • GPT-4 Vision Mini (gpt-4o-mini)
    • GPT-4.1 (gpt-4.1)
    • GPT-4.1 Mini (gpt-4.1-mini)
  • AWS Bedrock

    • Claude 3 Haiku (2024.03, 2024.10)
    • Claude 3 Sonnet (2024.02, 2024.06, 2024.10)
    • Claude 3 Opus (2024.02)
  • Google Gemini

    • Gemini 1.5 (Flash, Flash-8B, Pro)
    • Gemini 2.0 (Flash, Flash-Lite)
…

Python Zerox

(Python SDK - supports vision models from different providers like OpenAI, Azure OpenAI, Anthropic, AWS Bedrock, etc.)

Installation

  • Install poppler on the system, it should be available in path variable. See the pdf2image documentation for instructions by platform.
  • Install py-zerox:
bash
pip install py-zerox

The pyzerox.zerox function is an asynchronous API that performs OCR (Optical Character Recognition) to markdown using vision models. It processes PDF files and converts them into markdown format. Make sure to set up the environment variables for the model and the model provider before using this API.

Refer to the LiteLLM Documentation for setting up the environment and passing the correct model name.

Usage

…

Parameters

python
async def zerox(
    cleanup: bool = True,
    concurrency: int = 10,
    file_path: Optional[str] = "",
    maintain_format: bool = False,
    model: str = "gpt-4o-mini",
    output_dir: Optional[str] = None,
    temp_dir: Optional[str] = None,
    custom_system_prompt: Optional[str] = None,
    select_pages: Optional[Union[int, Iterable[int]]] = None,
    **kwargs
) -> ZeroxOutput:
  ...

Parameters

  • cleanup (bool, optional): Whether to clean up temporary files after processing. Defaults to True.
  • concurrency (int, optional): The number of concurrent processes to run. Defaults to 10.
  • file_path (Optional[str], optional): The path to the PDF file to process. Defaults to an empty string.
  • maintain_format (bool, optional): Whether to maintain the format from the previous page. Defaults to False.
  • model (str, optional): The model to use for generating completions. Defaults to "gpt-4o-mini". Refer to LiteLLM Providers for the correct model name, as it may differ depending on the provider.
  • output_dir (Optional[str], optional): The directory to save the markdown output. Defaults to None.
  • temp_dir (str, optional): The directory to store temporary files, defaults to some named folder in system's temp directory. If already exists, the contents will be deleted before Zerox uses it.
  • custom_system_prompt (str, optional): The system prompt to use for the model, this overrides the default system prompt of Zerox.Generally it is not required unless you want some specific behavior. Defaults to None.
  • select_pages (Optional[Union[int, Iterable[int]]], optional): Pages to process, can be a single page number or an iterable of page numbers. Defaults to None
  • kwargs (dict, optional): Additional keyword arguments to pass to the litellm.completion method. Refer to the LiteLLM Documentation and Completion Input for details.

Returns

  • ZeroxOutput: Contains the markdown content generated by the model and also some metadata (refer below).

Example Output (output from "azure/gpt-4o-mini")

Note the output is manually wrapped for this documentation for better readability.

…

java\n' + 'int numUnits;\n' + 'double costPerUnit;\n' + 'char firstInitial;\n' + 'boolean isStudent;\n' + '

…

`

Supported File Types

We use a combination of libreoffice and graphicsmagick to do document => image conversion. For non-image / non-PDF files, we use libreoffice to convert that file to a PDF, and then to an image.

…

Credits

  • Litellm: https://github.com/BerriAI/litellm | This powers our python sdk to support all popular vision models from different providers.

License

This project is licensed under the MIT License.

Issues· 91 open

View all issuesOpen on GitHub
  • #206

    OS command injection via document URL extension reaches pdfinfo/pdftoppm shell exec (unauthenticated RCE)

    Updated Jun 12, 2026
  • #201

    [Python SDK] Feature Parity Gap: `errorMode`, `correctOrientation`, `trimEdges`, `schema`, and `extractPerPage` Missing vs Node.js SDK

    Updated May 27, 2026
  • #190

    Support passing api_key via kwargs instead of only environment variables

    Updated Apr 12, 2026
  • #200

    Jay shree ram

    Updated Dec 31, 2025
  • #199

    Ashish Kumar mahato

    Updated Dec 31, 2025
  • #198

    Mahato

    Updated Dec 31, 2025
  • #197

    Ai dubbing

    Updated Dec 31, 2025
  • #196

    Jay shree ram

    Updated Dec 31, 2025
  • #193

    Security Vulnerabilities in SheetJS Dependency (xlsx npm package)

    Updated Nov 9, 2025
  • #192

    Output repeats

    Updated Sep 19, 2025

> Tags

TypeScriptocrpdf

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言