CLI#
Use the CLI when you want to validate a backend, transcribe one image, or extract page crops without writing Python.
Use churro-ocr --help or python -m churro_ocr --help to inspect the top-level commands.
Install the CLI#
Python 3.12 or newer is required.
uv tool install churro-ocr
If you are adding churro-ocr to a project instead, use uv add churro-ocr and prefix the commands on this page with uv run.
Install a Runtime#
Choose the optional runtime that matches the backend or feature you want to use:
Target |
Command |
Use it when |
|---|---|---|
|
|
you want local Transformers OCR in-process |
|
|
you want hosted multimodal OCR through LiteLLM-backed providers |
|
|
you have a local or self-hosted OpenAI-style server |
|
|
you want Azure Document Intelligence OCR or page detection |
|
|
you want Mistral OCR |
|
|
you want |
|
|
you want every optional runtime in one environment |
Use --torch-backend with hf or all when you need a specific PyTorch build:
churro-ocr install hf --torch-backend cu126
The examples below use the local hf path first.
For backend choice and Python setup, continue with Providers And Configuration.
First Successful Transcription#
churro-ocr transcribe \
--image scan.png \
--backend hf \
--model stanford-oval/churro-3B
transcribe Examples#
Write OCR Text To A File#
churro-ocr transcribe \
--image scan.png \
--backend hf \
--model stanford-oval/churro-3B \
--output output.txt
This writes the OCR text to output.txt and prints that written path to stdout.
OCR With LiteLLM#
churro-ocr transcribe \
--image scan.png \
--backend litellm \
--model vertex_ai/gemini-2.5-flash
OCR With A Local OpenAI-compatible Server#
churro-ocr transcribe \
--image scan.png \
--backend openai-compatible \
--model local-model \
--base-url http://127.0.0.1:8000/v1
For vLLM or llama.cpp, serve the model separately with its OpenAI-compatible server and then use this same openai-compatible route.
See the official vLLM serving docs or the official llama.cpp serving docs.
extract-pages Examples#
Extract Pages From An Image#
churro-ocr extract-pages \
--image spread.jpg \
--output-dir pages/
This writes sequential PNG files such as page_0000.png, page_0001.png, and so on, and prints each written path to stdout.
Extract Pages With Azure Page Detection#
churro-ocr extract-pages \
--image spread.jpg \
--output-dir pages/ \
--page-detector azure \
--endpoint https://<resource>.cognitiveservices.azure.com/ \
--api-key <azure-doc-intelligence-key>
Extract Pages From A PDF#
Install pdf first if you have not already:
churro-ocr install pdf
Then extract rasterized PDF pages as PNG files:
churro-ocr extract-pages \
--pdf document.pdf \
--output-dir pages/ \
--dpi 300 \
--trim-margin 30
Use Page Detection when you want the Python API for detection only. Use OCR Workflows when you want page detection and OCR together in Python.
Command Contracts#
transcribe Backends#
|
Required flags |
Notes |
|---|---|---|
|
|
Uses LiteLLM credentials and routing. |
|
|
For local or self-hosted OpenAI-style servers. |
|
|
|
|
|
|
|
|
Local Transformers OCR. |
extract-pages Detectors#
|
Required flags |
Notes |
|---|---|---|
|
none |
Default behavior. Treats the whole image or rasterized PDF page as one crop. |
|
|
Uses |
|
|
Uses Azure Document Intelligence layout detection. |
Additional Rules#
transcriberequires exactly one--image.--outputwrites OCR text to a file and prints the written path.extract-pagesrequires exactly one of--imageor--pdf.--dpionly affects the--pdfpath because PDFs are rasterized before page detection.--trim-marginexpands each detected crop by the requested number of pixels, clipped to image bounds.