Invoice OCR supports multiple input formats for both images and PDFs. This page documents all supported request body structures across the API endpoints.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/bnishit/purchase-ocr/llms.txt
Use this file to discover all available pages before exploring further.
Image Requests
Base64 Encoded Image
The most common format for uploading images directly from client applications.Image data as a base64-encoded string or data URL
MIME type of the image (e.g., “image/png”, “image/jpeg”). Defaults to “image/png” if omitted.
- cURL
- JavaScript
- Python
Data URL Format
You can also pass a complete data URL (useful when reading from file inputs in the browser).When using a data URL, the
mimeType parameter is optional as it’s embedded in the data URL.PDF Requests
Public PDF URL
The simplest format for PDFs - provide a publicly accessible URL.Publicly accessible URL to the PDF document
Base64 Encoded PDF
For PDFs that aren’t publicly accessible or when uploading directly.PDF data as a base64-encoded string or data URL
- cURL
- JavaScript
- Python
PDF Data URL
Similar to images, you can use a data URL format:Advanced Options
Model Override
Override the default OpenRouter model for a specific request.OpenRouter model ID (e.g., “openai/gpt-4o”, “google/gemini-2.0-flash”)
PDF Plugin Configuration
Configure the PDF parsing engine and options.Array of OpenRouter plugin configurations. Typically used to override the PDF parser.
| Engine | Description | Use Case |
|---|---|---|
pdf-text | Fast text extraction (default) | Standard PDFs with selectable text |
mistral-ocr | OCR-based extraction | Scanned PDFs, image-based documents |
native | Native OpenRouter parsing | When you want model-native PDF handling |
If omitted, the system uses the
OPENROUTER_PDF_ENGINE environment variable (defaults to pdf-text).Annotations (Cost Optimization)
Reuse previously parsed PDF metadata to avoid redundant processing costs.OpenRouter annotations from a previous response. When provided, skips re-parsing the PDF.
- First request: Process PDF normally, save
annotationsfrom response - Subsequent requests: Include saved
annotationsto reuse parsed content - Cost savings: Avoid file-parser plugin charges on repeated requests
Example: Reusing Annotations
Example: Reusing Annotations
Complete Request Examples
Minimal Image Request
Full-Featured PDF Request
Cost-Optimized Repeated Request
Request Size Limits
Supported File Types
Images
- PNG (
.png) - JPEG (
.jpg,.jpeg) - WebP (
.webp) - BMP (
.bmp) - GIF (
.gif)
PDFs
- PDF 1.4 through 2.0
- Single or multi-page documents
- Text-based or scanned (with OCR engine)
Error Handling
Common request validation errors:| Error | Cause | Solution |
|---|---|---|
Missing image or PDF input | No image/PDF parameter provided | Include imageBase64, pdfUrl, or pdfBase64 |
Invalid base64 format | Malformed base64 string | Verify base64 encoding |
File too large | File exceeds 10 MB | Compress or reduce file size |
Invalid model ID | Unknown model specified | Use a valid OpenRouter model ID |
Related
OCR Endpoints
Explore all available API endpoints
Model Selection
Choose the right model for your use case
Processing PDFs
Guide to working with PDF documents
PDF Support
Learn about PDF processing features
