Building an Early-Access Receipt Scanner
Model availability
Use only model IDs returned by GET /v1/models. The current catalog does not include Gemini 3.
Keep your DocsRouter key on the server, send one receipt to /v1/ocr, and validate the returned content before displaying or storing it.
// app/api/scan/route.ts
import { NextResponse } from 'next/server';
export async function POST(request: Request) {
const { imageUrl } = await request.json();
const response = await fetch('https://api.docsrouter.com/v1/ocr', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.DOCSROUTER_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: imageUrl,
model: 'google/gemini-2.5-flash',
options: { output_format: 'json', extract_tables: true },
}),
});
const payload = await response.json();
return NextResponse.json(payload, { status: response.status });
}The endpoint does not validate a custom receipt schema or automatically retry with another model. Parse and validate merchant, date, currency, totals, and line items in your application. Send unreadable or inconsistent receipts to review.
No fixed accuracy or latency is promised; camera quality, layout, model choice, and provider load all affect results.