This project performs OCR (Optical Character Recognition) using free vision-enabled LLMs available on OpenRouter. No paid API keys, no subscriptions — just fully free OCR using models like:
- amazon/nova-2-lite-v1:free
- Any OpenRouter vision-capable free model
This allows you to extract text from images using modern LLMs at zero cost.
-
100% free OCR using OpenRouter’s free-tier models
-
Works with:
- 🌐 Image URLs
- 🖼️ Local images (converted to Base64)
-
Model-agnostic (works with any vision LLM on OpenRouter)
-
Preserves reading order and all visible text
-
Saves extracted text to a
.txtfile -
No OpenAI API key needed — only OpenRouter free API
- Python 3.7+
requestspython-dotenv(optional, for managing API key)
Install:
pip install requests python-dotenvAdd your OpenRouter API key to a .env file:
OPENROUTER_API_KEY=your_key_here
(You can use the free key available on your OpenRouter dashboard.)
OpenRouter allows sending image URLs or base64 images to free LLMs. This script sends:
- The instruction prompt
- The image as a URL or base64 data URL
And returns clean text extracted by the model.
Loads a local image and converts it to Base64.
Downloads the image → sends to LLM → extracts text.
Sends Base64 directly in a data:image/jpeg;base64,... format.
Both functions call a free OpenRouter LLM.
image_path = "image.jpg"
image_base64 = encode_image_to_base64(image_path)
text = image_to_text_from_base64(image_base64)
print(text)image_url = "https://example.com/sample.jpg"
text = image_to_text_from_url(image_url)
print(text)with open("extracted_text.txt", "w", encoding="utf-8") as f:
f.write(text)Modify:
"model": "amazon/nova-2-lite-v1:free"To any OpenRouter free vision model (if available):
"model": "qwen2.5-vision:free"
"model": "llama-vision-free"
"model": "openai/gpt-4o-mini:free"No other changes required.
Compared to traditional OCR tools, LLM OCR:
- Reads small & faint text
- Preserves formatting
- Handles mixed fonts
- Works on stylized documents
- Understands layout and context
And with OpenRouter free models — you pay nothing.
- OCR for receipts, invoices, IDs
- Text extraction from PDFs (after converting to images)
- Digitizing notes
- Document preprocessing for ML pipelines
- Free OCR for students & hobbyists
Feel free to submit pull requests for improvements:
- Model selector menu
- Export to JSON/Markdown
- Batch processing
- CLI tool
MIT License.