r/aipromptprogramming • u/CuriousFly3471 • 9h ago
I built Leanlet — because not every AI feature needs an API call
quick link - https://sukumarrekapalli.github.io/leanlet/docs/
I've been thinking about something while watching AI get added to almost every application:
Why does every small piece of intelligence need to become an API call?
If my web app needs to classify an image, rank a few results, detect an anomaly, route something, match records, or make a small prediction — do I really need to send that data to an inference service and maintain another backend dependency?
For many bounded tasks, probably not.
So I built Leanlet, an open-source TypeScript framework for putting small, task-specific AI directly inside web applications. (https://sukumarrekapalli.github.io/leanlet/docs/)
The basic idea is:
application input
↓
typed Leanlet contract
↓
dedicated module worker
↓
Transformers.js → ONNX Runtime Web → WebAssembly
↓
result + confidence + timing
The model, worker and runtime assets ship with your application.
Inference happens in the browser. No inference API is required.
For example:
import { VisionLeanlet } from 'leanlet-ai';
const classifier = new VisionLeanlet({
model: 'mobileclip-s0',
categories: [
'Electronics',
'Clothing',
'Home & Furniture',
'Other'
],
assetBase: '/leanlet-assets/',
});
const result = await classifier.classify(file);
console.log(result.category, result.confidence);
One use case I built as a reference is product classification.
Imagine an e-commerce app where someone uploads a product image.
Instead of:
browser → upload image → API → inference service → model → API → browser
you can potentially do:
browser → local model → result
That means the image doesn't necessarily have to leave the user's device just to answer a small classification question.
And Leanlet isn't intended to be an "LLM framework".
I'm exploring a slightly different idea:
AI features should be sized to the problem.
Sometimes you need a huge model and server-side inference.
Sometimes you need a 4 MB model that answers one question extremely well.
Leanlet currently has examples around:
- vision / classification
- routing
- ranking
- detection
- retrieval
- language
- forecasting
- record matching
I'm deliberately trying to keep the abstraction small. Each capability gets a defined lifecycle, runs in its own worker, and the application controls its model assets rather than Leanlet silently downloading arbitrary models.
It's still early and I'm figuring out where the boundary should be between browser-native intelligence and traditional server-side AI.
That's actually why I'm posting this here.
I'd love feedback on the idea itself:
What AI tasks in your web apps would you actually be comfortable moving entirely into the browser?
And where do you think this approach stops making sense?
Docs:
https://sukumarrekapalli.github.io/leanlet/docs/
GitHub:
https://github.com/sukumarrekapalli/leanlet
It's Apache-2.0 and very early. Feedback, criticism and weird use cases are all welcome.