今日已更新 328 条资讯 | 累计 20300 条内容
关于我们

From N*M to N+M: A Zero-Dependency LLM Provider Layer

Santaz 2026年06月02日 20:39 3 次阅读 来源:Dev.to

There are only 3 LLM API protocols, but unlimited providers running the same protocol. Separate protocol from identity — protocol is code, provider is data — and complexity drops from N×M to N+M. 300 lines of TypeScript. Zero dependencies. The problem isn't "it doesn't work." It's "it won't tell you it broke." In May, I built a Claude Code skill called unblind . I use DeepSeek as my daily driver, but it can't see images. So unblind forwards images to Mimo and OpenAI's vision APIs. The MVP had two providers. A few dozen lines of if-else. It worked. Then I noticed something more unsettling: an expired API key — no warning. A network hiccup — no retry. A missing permission — silently skipped. This tool didn't fail. It quietly stopped working without telling you. I added Phase 0 self-healing, circuit breakers, persistent caching, and a security sandbox. Now unblind wouldn't fail silently. But then I noticed something else. The circuit breaker doesn't care if you're calling a vision API or a translation API. The cache doesn't care if the response is an image description or OCR text. The error normalization doesn't care whether the other end is Mimo or OpenAI. A universal provider infrastructure, trapped inside a vision skill. First attempt: follow the ecosystem, hit the ceiling The largest similar project in the ecosystem is vision-support, with 19 providers. The pattern is standard—base class + subclasses, GoF Template Method. I followed it for v2.0. class BaseProvider { async analyzeImage ({ image , prompt , options }) { const { url , body , headers } = this . _buildRequest ( image , prompt , options ); const res = await apiRequest ( url , { body , headers }); return { content : await this . _parseResponse ( res ), model : this . _model }; } } class MimoProvider extends BaseProvider { ... } // 54 lines class OpenAIProvider extends BaseProvider { ... } // 45 lines class GeminiProvider extends BaseProvider { ... } // ~50 lines One subclass per provider. I expanded unblin

本文内容来源于互联网,版权归原作者所有
查看原文