Skip to main content
FastOCR

A LlamaIndex reader that reads scanned PDFs and images with FastOCR and returns their text.

CI PyPI Python License: MIT

Website · Docs · Get an API key

FastOCR reads a scanned page in English, Arabic and Hindi and returns its text

Quickstart

pip install llama-index-readers-fastocr
export FASTOCR_API_KEY="your_api_key"
from llama_index.readers.fastocr import FastOCRReader

documents = FastOCRReader().load_data("scanned_contract.pdf")
print(documents[0].text)

Python 3.10 or newer. The distribution is llama-index-readers-fastocr and the import is llama_index.readers.fastocr.

What you get back

FastOCRReader.load_data returns one Document per file.

You get Where
The text of the whole file text
The file's path and name metadata["source"], metadata["file_name"]
The FastOCR document id metadata["fastocr_document_id"]
Pages billed metadata["pages_billed"]
completed or partial metadata["status"]
A searchable PDF, with output="pdf" saved as <name>.searchable.pdf beside the input; its path is in metadata["searchable_pdf_path"]

The FastOCR keys (fastocr_document_id, pages_billed, status, searchable_pdf_path) are left out of the text that embedding models and LLMs see. Pass extra_info={...} to load_data to add your own metadata.

If the account runs out of pages partway through a file, you still get the text of the pages that were processed, with status set to partial and a warning in the log. A document that fails raises the error from fastocr-sdk with its message and code.

Languages and files

  • 100+ languages, detected automatically. No language setting is needed.
  • PDF files up to 1 GiB, and PNG, JPG, JPEG, GIF, WebP and BMP images up to 20 MiB. An image counts as one page.

Get an API key and pages

Any signed-in FastOCR account can create an API key and start right away.

  1. Sign in and create an API key in the developer console. You accept the API terms with your first key.
  2. Set the key as FASTOCR_API_KEY, or pass api_key= to the reader.
  3. When you need more than the free pages, buy a Page Pack on the pricing page. Packs work on the website and in the API.

Every account gets 50 free pages a month, shared with PDFs on the website. An image sent to the API is one page.

Examples

RAG over scanned PDFs

from llama_index.core import VectorStoreIndex
from llama_index.readers.fastocr import FastOCRReader

documents = FastOCRReader().load_data("scanned_contract.pdf")
index = VectorStoreIndex.from_documents(documents)
print(index.as_query_engine().query("When can the contract be terminated?"))

This example uses LlamaIndex's default OpenAI models, so it needs OPENAI_API_KEY. Set another embedding model and LLM in Settings to use a different provider.

A folder of scans

from pathlib import Path

from llama_index.readers.fastocr import FastOCRReader

scans = sorted(p for p in Path("scans").iterdir() if p.suffix.lower() in {".pdf", ".png", ".jpg", ".jpeg"})
for document in FastOCRReader().load_data(scans):
    print(document.metadata["file_name"], document.metadata["pages_billed"])

The reader runs one file at a time and returns when all files are done.

Use it with SimpleDirectoryReader

from llama_index.core import SimpleDirectoryReader
from llama_index.readers.fastocr import FastOCRReader

documents = SimpleDirectoryReader(
    "scans",
    file_extractor={".pdf": FastOCRReader(), ".png": FastOCRReader(), ".jpg": FastOCRReader()},
).load_data()

Searchable PDFs for an archive

from llama_index.readers.fastocr import FastOCRReader

documents = FastOCRReader(output="pdf").load_data(["invoice-001.pdf", "invoice-002.pdf"])
for document in documents:
    print(document.metadata["searchable_pdf_path"])

Each searchable PDF is saved beside its input, as invoice-001.searchable.pdf. An existing file with that name is replaced. Index the text and keep the PDF.

Options

Argument Default Meaning
api_key FASTOCR_API_KEY Your FastOCR API key
output "text" "pdf" also saves a searchable PDF beside each input
base_url FASTOCR_BASE_URL, then https://api.fastocr.org API address
timeout 300.0 Seconds to wait for each document

load_data(file_path, extra_info=None) takes one path or a list of paths.

Support and license

Questions: support@fastocr.org. Bugs and requests: GitHub issues. MIT license; see LICENSE.

Metadata

Release files for llama-index-readers-fastocr 0.1.1

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

Source distribution (sdist)

Source distribution for llama-index-readers-fastocr 0.1.1
File Size Uploaded Provenance
llama_index_readers_fastocr-0.1.1.tar.gz 3.1 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-readers-fastocr 0.1.1
File Interpreter ABI Platform
llama_index_readers_fastocr-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 3.1 MB

Release files / llama_index_readers_fastocr-0.1.1.tar.gz

Download URL llama_index_readers_fastocr-0.1.1.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
860b593d3b6635937a1d6eacc29e5d2a3b7515233841ad51249b78794c5ad0b9
BLAKE2b-256 checksum
How to use checksums
75b7a16e2b99e12caf8332f221718aa1ae122d6ae6c795182b0b797d04fe1a33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 25, 2026.

Transparency log

Release files / llama_index_readers_fastocr-0.1.1-py3-none-any.whl

Download URL llama_index_readers_fastocr-0.1.1-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30aa2caa3e86427eaf8d5fe91ab8552a9e033ba1ee9c46a3e11de4d9ea90aae4
BLAKE2b-256 checksum
How to use checksums
8036c628ab584feeddd205a28ed355ee5627a6ec09ac9dee665a9ad7ef6183b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 25, 2026.

Transparency log

Security for llama-index-readers-fastocr 0.1.1

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 llama_index_readers_fastocr-0.1.1.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 Oct 25, 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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