So I built CostLens. It's a drop-in replacement that automatically routes requests to cheaper models when possible, but falls back to premium ones when quality matters.
How it works: js // Just swap this: const openai = new OpenAI({ apiKey: 'sk-...' });
// For this: const costlens = new CostLens(); const openai = costlens.openai({ apiKey: 'sk-...' }); // Everything else stays exactly the same
Real savings: • Simple tasks: GPT-4 → GPT-4o-mini (95% cheaper) • Complex tasks: Still uses GPT-4 when needed • My bills dropped ~70% with zero code changes
Features: • Quality detection (auto-retries with better models if response is bad) • Works with existing code - no prompt changes needed • Caching with Redis • Instant mode (no signup required)
Try it: npm install costlens
The core SDK is free and works locally. I'm also building a dashboard for teams to track their AI spending.
NPM: https://www.npmjs.com/package/costlens
Anyone else tired of overpaying for AI APIs? What's your biggest cost pain point?