How I cut LLM token cost by 70% at Mapin
At Mapin Data I built an end-to-end extraction pipeline in Python that turns unstructured web pages, PDFs and QR codes into structured data. It used FireCrawl for crawling, OpenCV for image preprocessing and QR decoding, and Vision-Language Models for document understanding. The output was mapped, together with the core team, into a production-ready JSON schema for downstream AI tasks.
I reduced LLM token costs by 70% while keeping extraction accuracy at around 80%. The internals belong to the company, so this note stays at the level of the approach.
Lever 1: send fewer tokens
I designed custom text-chunking algorithms to control what text reaches the model, and in what pieces. Fewer input tokens per document means lower cost on every call.
Lever 2: send them to the right model
Model routing on OpenRouter means each request does not have to go to the same model. The routing was optimised so that cost dropped without giving up the accuracy target.
What I took away
- Measure cost and accuracy together: a cheaper pipeline only counts if extraction quality holds.
- Input size and model choice are separate levers, and they compound.
- A fixed output schema makes quality checkable and keeps downstream consumers stable.