1 unstable release
Uses new Rust 2024
| 0.2.0 | Feb 19, 2026 |
|---|
#1572 in Text processing
63KB
597 lines
Mistral OCR
Convert PDF, image, and document files into Markdown using Mistral AI's OCR API. Written in Rust.
Available as a CLI tool (mistral_ocr) and a GUI app (mistral_ocr_gui).
Features
- Supports PDF, images (jpg, png, gif, bmp, tiff, webp), and office documents (docx, odt, pptx, xlsx, etc.)
- PDF and image files require no external dependencies — just the binary and an API key
- Office documents (docx, odt, pptx, etc.) are automatically converted to PDF via LibreOffice
- Multiple image handling modes:
- separate — save images as files in a
_images/directory - inline — embed images as base64 data URIs (single self-contained
.mdfile) - zip — bundle markdown + images into a single
.ziparchive
- separate — save images as files in a
- Cross-platform: works on Linux, macOS, and Windows
Installation
Prerequisites
- A Mistral API key
- LibreOffice — only needed if you process office documents (docx, odt, pptx, xlsx, etc.). Not required for PDF or image files.
CLI (pre-built binary)
cargo binstall mistral_ocr
CLI (from source)
cargo install mistral_ocr
GUI (pre-built binary)
cargo binstall mistral_ocr_gui
GUI (from source)
cargo install mistral_ocr_gui
Configuration
Set your Mistral API key as an environment variable (the GUI also accepts it in the UI):
export MISTRAL_API_KEY='your-api-key-here'
CLI Usage
Basic usage (text only)
mistral_ocr document.pdf
Process an image
mistral_ocr photo.png
Process a Word document
mistral_ocr report.docx --images inline
Extract images as separate files
mistral_ocr document.pdf --images separate
Single self-contained markdown file
mistral_ocr document.pdf --images inline
Bundle everything into a zip
mistral_ocr document.pdf --images zip
All options
<INPUT> Path to the input file (required)
--images <MODE> How to handle images: none, separate, inline, zip (default: none)
--output <PATH> Where to write the output (default: ocr_output.md)
Supported file types
| Type | Extensions | Requires LibreOffice? |
|---|---|---|
| No | ||
| Images | jpg, jpeg, png, gif, bmp, tiff, webp | No |
| Documents | doc, docx, odt, rtf, txt, html, pptx, ppt, odp, xlsx, xls, ods, csv, epub | Yes |
Project Structure
This is a Cargo workspace with two crates:
mistral_ocr— library + CLI binary (published on crates.io)mistral_ocr_gui— GUI binary using egui
License
MIT — see LICENSE.
Dependencies
~23–51MB
~754K SLoC