A minimal Mistral API wrapper to OCR images and PDF with images embedded in the resultant markdown.
1. Install dependencies
pip install -r requirements.txt
2. Setup environment variables
Create a .env file in the project root and paste the following:
# Put your Mistral API key here
MISTRAL_API_KEY=YOUR_API_KEY_HERE
# Optional: override model name
MISTRAL_OCR_MODEL=mistral-ocr-latest
3. Run the example script
python src/main.py
- main.py — example usage. The output is stored in
.mdfile. - mistral_ai.py — contains the
MistralClient.
- Documentation: https://docs.mistral.ai/capabilities/document_ai/basic_ocr/
- API Reference: https://docs.mistral.ai/api/#tag/ocr
- PDF: https://github.com/mistralai/cookbook/blob/main/mistral/ocr/mistral7b.pdf
- Image: https://gallica.bnf.fr/ark:/12148/bpt6k850660r/f26.item
Author: Mayank 'DerperDoing' Bagchi