Base URL
All API endpoints are relative to your deployment base URL:Authentication
The API uses OpenRouter for model inference. Configure your OpenRouter API key in the environment:.env.local
Environment Configuration
Your OpenRouter API key (required)
Default model for inference. Can be overridden per request.
Your site URL for OpenRouter HTTP-Referer header
Application name for OpenRouter X-Title header
PDF parsing engine:
pdf-text, mistral-ocr, or nativeEndpoints
OCR Extraction Endpoints
POST /api/ocr
Extract raw text from images or PDFs without structuring
POST /api/ocr-structured
Extract structured JSON using MyBillBook schema with reconciliation
POST /api/ocr-structured-v4
Advanced India GST schema with comprehensive reconciliation
GET /api/models
List available vision-capable OpenRouter models
Input Formats
All endpoints support multiple input formats:- Base64 Image:
imageBase64parameter with optionalmimeType - Data URL:
imageBase64withdata:image/png;base64,...format - PDF URL:
pdfUrlparameter with publicly accessible URL - Base64 PDF:
pdfBase64parameter
Response Format
All endpoints return JSON responses: Success (200)Model Selection
You can override the default model per request:openai/gpt-4o-mini- Fast and cost-effectiveopenai/gpt-4o- Higher accuracygoogle/gemini-2.0-flash- Excellent for PDFsanthropic/claude-3.5-sonnet- High quality extraction
Error Handling
Common error scenarios:Missing Input (400)
Missing Input (400)
Missing API Key (500)
Missing API Key (500)
OPENROUTER_API_KEY in your environment.OpenRouter Error (500)
OpenRouter Error (500)
No Content Returned (500)
No Content Returned (500)
Rate Limits
Rate limits are determined by your OpenRouter plan. The API does not impose additional limits.Best Practices
Choose the Right Endpoint
Use
/api/ocr-structured-v4 for India GST invoices, /api/ocr-structured for simpler formatsHandle Reconciliation
Check
reconciliation.status in structured responses to detect calculation mismatchesNext Steps
Raw Text Extraction
Learn about the
/api/ocr endpointStructured Extraction
Explore the MyBillBook schema
V4 Schema
Advanced India GST extraction
Request Formats
Learn about all supported input formats
