Metadata-Version: 2.4
Name: pdf2mela
Version: 0.1.1
Summary: Convert PDF recipes to .melarecipe format using Mistral OCR
Project-URL: Homepage, https://github.com/jjakubassa/pdf2mela
Project-URL: Issues, https://github.com/jjakubassa/pdf2mela/issues
Author-email: Jonas Jakubassa <jakubassa@posteo.de>
License: MIT
License-File: LICENSE
Keywords: mistral,ocr,recipes
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.11
Requires-Dist: loguru>=0.7.3
Requires-Dist: mistralai>=1.12.4
Requires-Dist: pydantic>=2.12.5
Requires-Dist: tenacity>=9.1.4
Requires-Dist: tyro>=1.0.8
Description-Content-Type: text/markdown

# pdf2mela

Convert scanned PDF recipes to [Mela](https://mela.recipes) format using Mistral OCR.

- Single PDF → `.melarecipe` (JSON)
- Multiple PDFs → `.melarecipes` (ZIP)

## Requirements

- Python 3.11+
- A [Mistral API key](https://console.mistral.ai)

## Installation

Install as tool with `uv` (recommended):

```sh
uv tool install pdf2mela
```

Or with `pip`:

```sh
pip install pdf2mela
```

Or run it directly without installing:

```sh
uvx pdf2mela --inputs recipe.pdf
```

## Usage

```sh
# Single file
pdf2mela --inputs recipe.pdf

# Multiple files
pdf2mela --inputs recipe1.pdf recipe2.pdf

# Whole directory
pdf2mela --inputs ./scans/

# Custom output directory
pdf2mela --inputs ./scans/ --output ./mela/

# Explicit API key
pdf2mela --inputs recipe.pdf --api-key YOUR_KEY
```

The Mistral API key is read from the `MISTRAL_API_KEY` environment variable by default.

## Pricing

Mistral OCR costs **$2 per 1,000 pages**. The tool prints an estimated cost at the end of each run, including what it would have cost with the 50% batch discount. See [Mistral's pricing page](https://mistral.ai/pricing#api) for up-to-date rates.

## Notes

- Recipes are extracted in their original language — no translation is applied.
- All PDFs in a run are processed concurrently.
- Failed requests are retried up to 3 times with exponential backoff.
- Set `LOGLEVEL=DEBUG` to see raw OCR responses.
