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. For bank statements, see the next section.

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.

Bank statements (beta)

FastOCRBankStatementReader reads bank statements (PDF, PNG, JPG, JPEG or WebP) and returns one Document per transaction. A transaction is what people ask about ("what did I pay this shop?"), so each one is its own node to embed and retrieve; the statement-level facts sit in every document's metadata.

from llama_index.readers.fastocr import FastOCRBankStatementReader

documents = FastOCRBankStatementReader().load_data("october-statement.pdf")
print(documents[0].text)  # 2026-10-02 | Coffee | out 5.00 USD | balance 95.00
You get Where
Date, description, signed amount and balance of one transaction text
Bank, account number, currency metadata["bank"], metadata["account_number"], metadata["currency"]
Which account of the statement (1 is the first) metadata["account"]
Date, amount, in or out, balance, page metadata["date"], ["amount"], ["direction"], ["balance"], ["page"]
verified, check or unchecked metadata["status"]
True when a person should check the statement metadata["needs_review"]
The statement id metadata["fastocr_statement_id"]

The statement id, account, account number, page, status and needs_review are left out of the text that embedding models and LLMs see; the bank, currency, date, amount, direction and balance stay in it. Pass extra_info={...} to load_data to add your own metadata. Bank statement pages are a separate balance, shared with the website's bank statement converter. A statement with no transactions gives no documents and a warning in the log; a failed one raises the SDK's StatementFailedError. Options: api_key, base_url and timeout (600 seconds by default).

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 20 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.2.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 llama-index-readers-fastocr 0.2.0
File Size Uploaded Provenance Actions
llama_index_readers_fastocr-0.2.0.tar.gz 3.1 MB With provenance Details for llama_index_readers_fastocr-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 3.1 MB

Release files / llama_index_readers_fastocr-0.2.0.tar.gz

Download URL llama_index_readers_fastocr-0.2.0.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
056bf4460a384915bae999465759def180cef7598c2420bf5b3b223ab6b5fdcc
BLAKE2b-256 checksum
How to use checksums
530e680b9dcf7a60f1dc5cd72f80a14114813bd580d76ac06f5668b1745fca3e
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 Nov 6, 2026.

Transparency log

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

Download URL llama_index_readers_fastocr-0.2.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
601537951444e6f4ffa97560a707a79f2a9701937c334204e95e366256c90730
BLAKE2b-256 checksum
How to use checksums
dd11b996982d8a5c8cb157cac5afdac19abd137db5ccd469e181edc6ab8a23f2
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 Nov 6, 2026.

Transparency log

Security for llama-index-readers-fastocr 0.2.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llama_index_readers_fastocr-0.2.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 Nov 6, 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