Self-Hosted Real-Time KYC Image-to-Text API
Financial Services — Real-Time KYC Verification API
A document-quality gate and an AI reader working together, so a bad photo never wastes an extraction call and a good one gets structured data back in seconds.
Six-stage pre-AI quality gate, perspective-transform deskewing, self-hosted vision-language model extraction, and a fully async FastAPI + Celery + Redis pipeline with guaranteed cleanup.
Client scale: $7B gold-lending operations
09 / FINANCIAL SERVICES / IDENTITY VERIFICATION
A document-quality gate and an AI reader working together, so a bad photo never wastes an extraction call and a good one gets structured data back in seconds.
Client: Banking & financial services firm
Tags: Banking · KYC · Multilingual OCR · Computer Vision · Async Processing
Context
Verifying identity and banking documents at volume meant handling whatever a customer's phone camera actually produced — blurry, glared, dark, skewed, or genuinely unreadable images mixed in with good ones — across documents issued in multiple languages and scripts, for a use case where extraction accuracy on sensitive financial and identity data wasn't negotiable.
The Contribution
Built an asynchronous KYC document API that filters before it extracts. Every submitted image passes through a six-stage quality gate — blur, resolution, contrast, glare, darkness, and edge density — before anything is sent to an AI model at all; a document that fails any check is rejected immediately with a specific, actionable reason. Images that pass are automatically detected by their four-point outline and corrected with a perspective transform to a clean top-down view, then sent to a self-hosted, open-source vision-language model under a strict JSON-only extraction prompt. The whole pipeline runs asynchronously: a client submits an image and gets a task ID back immediately, processing happens on a Celery worker pool backed by Redis.
Technical Details
- Six-stage pre-AI image quality gate: blur (Laplacian variance), resolution, contrast, glare (bright-pixel ratio), darkness, and edge density
- Four-point document contour detection with perspective-transform deskewing to a top-down crop before extraction
- Extraction via a self-hosted, open-source vision-language model under a strict JSON-only response contract
- Fully asynchronous FastAPI + Celery + Redis pipeline: submit → immediate task ID (HTTP 202) → poll for result
- Automatic retries (up to 3) with backoff on transient task failures
- Hard/soft task time limits (5 min / 4 min) preventing runaway jobs; results expire after 30 minutes
- Guaranteed image file cleanup after every run, success or failure
- API-key authenticated endpoints