SuperAPIAI Directory

text-extract-api

github.com · AI images

document (PDF, Word, PPTX ...) extraction and parse API using OCRs + Ollama supported models. Anonymize documents. Remove PII. Convert any document or picture to structured JSON or Markdown

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

text-extract-api is a document extraction and parsing API designed to convert any image, PDF, or Office document into Markdown text or a JSON structured document with high accuracy, including table data, numbers, or mathematical formulas.

Purpose and main capabilities

  • Document conversion: Supports converting formats such as PDF, Word, PPTX, and images into Markdown or JSON.
  • OCR integration: Uses multiple OCR strategies, including EasyOCR, llama3.2-vision, minicpm-v, and remote marker-pdf, to improve recognition accuracy.
  • LLM processing: Post-processes OCR results through Ollama-supported models (such as Llama 3.1), which can correct spelling and text errors, or generate structured JSON according to prompts.
  • Anonymization and PII removal: The tool can be used to remove personally identifiable information from documents to achieve anonymization.
  • Asynchronous processing: Built on FastAPI, using Celery for asynchronous task processing and Redis for caching OCR results.
  • Storage strategies: Supports switchable storage strategies, including local file system, Google Drive, Amazon S3, etc.
  • CLI tool: Provides a command-line tool for submitting tasks and processing results.
  • No external cloud dependency: All required components (PyTorch-based EasyOCR + Ollama) are packaged via docker-compose, and data is not sent outside the development/server environment.

Usage

Quick start

  • Download and install Ollama and Docker.
  • Clone the repository and enter the directory.
  • You can use the Makefile for setup: by default it creates a Python virtual environment .venv, which can be disabled with DISABLE_VENV=1.
  • Configure environment variables (using the default values is usually sufficient), then run the installation command.
  • On Mac, you need to start the Celery worker.
  • Run CLI commands to perform operations.

Docker method

  • Create a .env file in the root directory and set environment variables; refer to .env.example.
  • You may need to modify the default storage path in storage_profiles/default.yaml to match docker-compose.yml volume paths.
  • Use Docker Compose to build and run the containers; GPU support requires the corresponding commands.
  • The services started include: FastAPI application, Celery Worker, Redis, Ollama.
  • Note: Docker on Mac does not support Apple GPU; consider running natively.

Remote Ollama

  • Set the environment variable OLLAMA_HOST=http://address:port to connect to an external Ollama instance.
  • If you need to disable the local Ollama model, set DISABLE_LOCAL_OLLAMA=1, and ensure the external instance has downloaded the required models.
  • Currently DISABLE_LOCAL_OLLAMA cannot disable Ollama in Docker; you need to remove the ollama service from the docker-compose file.

API endpoints

  • OCR upload: /ocr/upload (multipart form) or /ocr/request (Base64 JSON). Parameters include file, strategy (llama_vision, minicpm_v, remote, easyocr), ocr_cache, prompt, model, storage_profile, storage_filename, language.
  • Get OCR result: /ocr/result/{task_id}.
  • Clear OCR cache: /ocr/clear_cache.
  • Ollama pull model: /llm/pull, parameter model.
  • Ollama generate: /llm/generate, parameters prompt, model.
  • Storage list: /storage/list, parameter storage_profile.
  • Storage download: /storage/load, parameters file_name, storage_profile.
  • Storage delete: /storage/delete.

CLI examples

  • Upload a file for OCR (convert to Markdown)
  • Upload a file for OCR (LLM processing)
  • Specify storage_profile and storage_filename to save the result.

OCR strategies

  • EasyOCR: Enabled by default, supports more than 30 languages, with the best performance in English. Use via strategy=easyocr.
  • MiniCPM-V: Enabled by default, use via strategy=minicpm_v. Model weights must follow the MiniCPM Model License; free for academic research, and free for commercial use after filling out the questionnaire.
  • LLama 3.2 Vision: Default strategy, used via strategy=llama_vision. Supports multiple languages, but has many parameters (90b), so it may be slower.
  • Remote marker-pdf: Must be configured separately, used via strategy=remote. Supports more than 50 languages, but uses the GPL3 license and is not included by default. The weights license is cc-by-nc-sa-4.0, with an exemption for organizations with annual revenue below $5 million and funding below $5 million, and it must not compete with the Datalab API.

Use cases

  • Situations where scanned documents, images, or Office files need to be converted into editable text or structured data.
  • Processing complex documents containing tables and formulas.
  • Scenarios with high data privacy requirements, where documents need to be processed locally or on your own server.
  • Anonymization processing that requires removing personally identifiable information from documents.

Limitations

  • Docker on Mac does not support Apple GPU; native execution is required to use the GPU.
  • The DISABLE_LOCAL_OLLAMA variable is currently unavailable in Docker, and the compose file must be modified manually.
  • Some OCR strategies (such as marker-pdf) are not included by default due to licensing.
  • Before using an LLM for processing, the corresponding model must first be pulled via /llm/pull.
  • Detailed pricing or feature descriptions for the paid cloud version are not yet provided.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools