How I cut the AI cost of an Arabic OCR pipeline about tenfold
The registry has to stay free, so the pipeline behind it had to get cheap. These are the layers that did it, in the order a post meets them.
By Firas Mohammed · · 4 min read
The short answer
I cut the AI spend of an Arabic document pipeline about tenfold by making the model call the last step. Free deterministic checks go first. Every image is transcribed once with Google Cloud Vision. A cheap model screens the bulk, and only borderline posts reach the strong model, through the batch API at half price.
By October 2026 that pipeline had turned 106,595 posts and 133,161 photos into 679,162 searchable records for Arabati Wein, a free registry of vehicles looted in the Sudan war.
Where the money was going
The input is Arabic recovery lists from Sudanese Facebook groups and Telegram channels. A lot of it is photos of handwritten pages and registration cards. A chassis number stamped on a metal plate exists only in the image.
My first design sent every photo to a vision model. Then I benchmarked it, and the benchmark moved me to a dedicated OCR engine and a text-first pipeline. Every expensive decision on this project was one I'd made before I measured.
The layers, in order
- Scan for known identifiers deterministically. Before any model call, the numbers I'm looking for are matched token by token. Token by token matters: join a list of numbers into one string and digits from neighbouring entries form numbers that were never written. This scan costs nothing, and it's the only check allowed to declare a match on its own.
- Drop what can't hold a vehicle. A post with no vehicle vocabulary, no chassis-shaped number and no image never reaches a model. That relevance gate removed about 35% of the corpus.
- Hash the content. Recovery lists get cross-posted between groups, so one verdict serves every copy. Photos get the same treatment. When I hashed the photo backlog, 75% of it was byte-identical copies.
- Transcribe each image once. Google Cloud Vision read 24,928 images, 1.7 million characters, for about $35.80, roughly $1.50 per 1,000 images. After that the whole corpus is text, which is cheaper to score and easier to check. I also benchmarked a competing model. It would have cost about $145 for the backlog, and on 17 chassis numbers read off photos it found 13 where Cloud Vision found 14.
- Tier the models. A cheap model screens everything and only borderline posts escalate. On my fallback vendor the two tiers are 20 times apart in price. I priced a 744-post backlog: screening it all on the cheap tier came to under $1, and escalating the roughly 15% that survived brought the run to about $4. The strong tier alone would have cost $15 to $40 for the same answers.
One exception to the tiers. A post whose chassis number sits in a photo goes straight to the strong model at high image detail. The stamp is unreadable in the thumbnail a screening pass sees, and a cheap pass scoring that post 0 would bury exactly the number a family is searching for.
Batch, fallback, and a sample
Anything that can wait goes through the batch API at half price. A repeated system prompt is also cached at 90% off.
When Claude hits a spend limit, a rate limit or an outage, the post retries on OpenAI and the verdict is tagged with the model that produced it. Without that, a cap drops posts silently. My first fallback could never have answered a single call: it sent max_tokens, and the OpenAI model I used only accepts max_completion_tokens.
Sample the queue before you trust a projection. The first 25 unscored posts were image-heavy and implied a $37 run. The whole backlog held 71 image posts against 709 text-only ones. The real figure was about $7.
What Arabic adds
Arabic-Indic digits fold to Latin digits before any comparison. A Sudanese plate reads 12345 خ1, so plates match digit run by digit run. Glued together it becomes 123451, a number written nowhere.
Sudanese vehicle slang needs its own table. شريحة is a minibus, بوكس a pickup, دقو ورا a rickshaw. Before that table existed, a van was filed as a Corolla.
Questions people ask
Is Google Cloud Vision good enough for Arabic OCR?
For this corpus, yes. On 17 chassis numbers read off photos it got 10 exact and 4 within one character. DOCUMENT_TEXT_DETECTION beat TEXT_DETECTION, 10 exact to 9. Document AI costs the same $1.50 per 1,000 and is built for forms and tables, which this corpus isn't.
Should I send images straight to a multimodal LLM?
Only where the number you need lives in the image. My pipeline transcribes every photo once and scores text. Posts with a chassis number in a photo go to the strong model at high detail.
Which Claude model did you use for extraction?
Sonnet. In my benchmark Opus matched it on quality at about 4.7 times the cost and 2.4 times the time. Haiku analysed 1 of 21 posts and reported all 21 done.
Where it stands
Today the paid lanes are off. Photo OCR and prose extraction run on the Gemini free tier, and the same free checks still go first. The full project is in the vehicle recovery case study. Two other notes cover how to search the registry and how to catch silent data loss.
If your document pipeline costs more than it should, this is how I work.