Skip to main content

ocr-software

Python client and command line for the ocr-software.com OCR API. MIT, standard library only, Python 3.9 or newer.

Install

pipx install ocr-software        # command line only, in its own environment
pip install ocr-software         # client library, inside a venv
uvx ocr-software --version       # run once without installing (uv)

First call (list the pipelines, then read one file):

ocr-software --list-pipelines
ocr-software scan.pdf --pipeline scan-ctc@2 -o scan.txt

Settings

Environment variables; the command line flag wins.

Variable Meaning
OCR_SOFTWARE_API_KEY API key (starts with ocr_). OCR_KEY is read too, it is the name used in the API docs.
OCR_SOFTWARE_BASE_URL Default https://api.ocr-software.com; own server e.g. http://127.0.0.1:8080 (also --base-url). OCR_BASE_URL is read too.
OCR_SOFTWARE_ALLOWED_DIR Optional: read documents only from below this folder (symlinks and .. do not escape).

The key is never printed and never part of an error message. Without --pipeline the default is used: the fastest and cheapest available pipeline (no previews). It is named on stderr; --list-pipelines marks it. In Python: client.ocr(path, client.default_pipeline()).

Command line

ocr-software --list-pipelines                         # available pipelines, one per line: name@version, tab, what it delivers and costs; the default one on stderr (no key needed)
ocr-software scan.pdf --pipeline NAME@VERSION --dry-run   # page count and price in euros, nothing runs, nothing is billed
ocr-software scan.pdf                                 # text to stdout, with the default pipeline (named on stderr)
ocr-software scan.pdf --pipeline NAME@VERSION         # text to stdout
ocr-software scan.pdf -o scan.md --pipeline NAME@VERSION --format md
ocr-software scan.pdf -o scan.pdf.txt --pipeline NAME@VERSION
ocr-software scan.pdf -o searchable.pdf --pipeline NAME@VERSION --format pdf   # searchable PDF, -o is required
ocr-software scan.pdf --pipeline NAME@VERSION --format json > scan.json
ocr-software scan.pdf --pipeline NAME@VERSION --base-url http://10.0.0.5:8080  # your own server
python -m ocr_software ...                            # the same command without the script on PATH

Options:

  • --format text (default) | md | json | hocr | pdf
  • --dpi 150|200|300 (PDF render resolution)
  • --timeout SECONDS (wait for the job, default 3600)
  • --job-budget MILLICENTS (cap; ignored where billing is off)
  • --dry-run, --version

Without -o the result goes to stdout as UTF-8 (not for pdf). With -o the file appears whole or not at all, an existing file is replaced, and the input file itself is refused as output.

Exit codes

Code Meaning
0 done, every page read
1 error from the service or the network (message on stderr with the API error code, for example 401 unauthorized); also an address that does not answer: a typo and an outage look the same, so a script may retry this
2 wrong call: unreadable or unsupported input, output not writable, no key, malformed address (not http/https)
3 the job is done but a page failed or did not run, or the job stopped early: the result is written anyway, stderr says what is missing and names the job; treat the file as incomplete
4 the job did not finish within --timeout; it keeps running, stderr names the job

Python

from ocr_software import Client, PagesUnread
client = Client()                                    # key and address from the environment
text = client.ocr("scan.pdf", "NAME@VERSION", "md")  # bytes; raises PagesUnread (with .data) if a page was not read
pdf = client.ocr("scan.pdf", "NAME@VERSION", "pdf")  # searchable PDF
job = client.submit("scan.pdf", "NAME@VERSION")      # step by step: submit, wait, result
client.wait(job["job_id"]); client.result(job["job_id"], "json")
q = client.quote("scan.pdf", "NAME@VERSION")         # dry run: page count and price, nothing runs
from ocr_software import price_sentence; price_sentence(q)   # the same sentence as --dry-run, in euros

Price: the API counts money in millicents, 100,000 millicents = 1 EUR (a page of the cheapest pipeline costs 100 = EUR 0.001). Today nothing is charged ("you pay EUR 0.00 today"); the list price is shown for information. Free use has limits: fair usage; for more volume write to info@ocr-software.com.

Word boxes (json): box = [x0, y0, x1, y1] in pixels of the page image, origin top left; width, height and dpi of the page say which image. In PDF points: pixels * 72 / dpi. Per word, verified is true only where a second reader confirmed it (scan-vlm-ctc@2); safe_ok is always false today. Judge by confidence (0 to 1). Every field: reference.

Retries follow the API rules: 429, 500, 502, 503, 504 and network errors up to 5 times (waits 1, 2, 4, 8, 16 s or Retry-After). An upload the service cuts off (it does that beyond 2 uploads at once per key, instead of answering 429) counts like 429. If no connection can be made at all (wrong address, host down) it gives up after 2 retries and names the address: a few seconds, up to about 10 s on Windows, where a refused port itself takes 2 s per try (connect timeout 10 s). A Retry-After over 60 s (locked_out) is not waited for. A submit carries an Idempotency-Key, so a retry never creates a second job.

Every document is checked locally first: PDF, PNG, JPEG or TIFF by its first bytes, at most 100 MiB.

Paperless-ngx

Pre-consume script (sketch, not tried against a real Paperless; a non-PDF input keeps its file name but becomes a PDF):

#!/bin/sh
ocr-software "$DOCUMENT_WORKING_PATH" --pipeline NAME@VERSION --format pdf -o "$DOCUMENT_WORKING_PATH.ocr" && mv "$DOCUMENT_WORKING_PATH.ocr" "$DOCUMENT_WORKING_PATH"

with OCR_SOFTWARE_API_KEY and OCR_SOFTWARE_BASE_URL set in the environment of the Paperless container.

Tests

Fake local service, no network, no key:

python -m venv .venv
.venv/bin/pip install pytest                          # Windows: .venv\Scripts\pip install pytest
.venv/bin/python -m pytest -p no:cacheprovider .      # Windows: .venv\Scripts\python -m pytest -p no:cacheprovider .

Metadata

Release files for ocr-software 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 ocr-software 0.1.1
File Size Uploaded Provenance Actions
ocr_software-0.1.1.tar.gz 26.6 kB With provenance Details for ocr_software-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ocr-software 0.1.1
File Interpreter ABI Platform Actions
ocr_software-0.1.1-py3-none-any.whl Python 3 none any Details for ocr_software-0.1.1-py3-none-any.whl

Total release size: 43.4 kB

Release files / ocr_software-0.1.1.tar.gz

Download URL ocr_software-0.1.1.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bd3dc3b1326e7500e40ccac09e3936d6ffa0d9b14f7043fbc6afcb72a9cfeb8f
BLAKE2b-256 checksum
How to use checksums
0220e0a8002692cee51d75cdad340f1bbb18bf090d444df92c35ff23ff54db20
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 Nov 13, 2026.

Transparency log

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

Download URL ocr_software-0.1.1-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79a3fcacd20d32cddcc31731c555dc38b89ce088029c61a4c0e321e94c26d333
BLAKE2b-256 checksum
How to use checksums
e6f91b33b6a061b6bbfce8e49d04f37d42a710f63cb4bac2e9387156cf7b86c9
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 Nov 13, 2026.

Transparency log

Security for ocr-software 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

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

Select from 2 files

Attestation for ocr_software-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 Nov 13, 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