Loading...
Loading...
Smart routing for OpenAI and Anthropic APIs. Save 20-40% on typical workloads through automatic model selection. Real-time cost tracking and analytics.
From our beta testing and SDK usage
GPT-4 → GPT-3.5 routing
Smart model selection
Prompt optimization
Smart routing optimizes costs automatically
Setup time: 5 minutes • Results visible: 24 hours
Install once. Save money automatically.
No API key required - works immediately with any OpenAI or Anthropic code
import { CostLens } from 'costlens';
import OpenAI from 'openai';
// ✨ Instant mode - no API key needed!
const costlens = new CostLens();
const openai = new OpenAI({ apiKey: 'your-openai-key' });
const ai = costlens.wrapOpenAI(openai);
const response = await ai.chat.completions.create({
model: 'gpt-4', // Automatically routes to gpt-3.5-turbo
messages: [{ role: 'user', content: 'Hello!' }]
});
// Check your savings
const savings = await costlens.calculateSavings('gpt-4', [
{ role: 'user', content: 'Hello!' }
]);
console.log(`Save ${savings.savingsPercentage}% with ${savings.recommendedModel}`);
// Output: Save 97.9% with gpt-3.5-turboCost Tracking
Monitor and analyze your AI spending in real-time
Smart Model Routing
Routes simple tasks to GPT-3.5, complex ones to GPT-4
Response Caching
Identical requests return cached results (Starter+ plans)
Authentication Caching
Faster API authentication with secure caching
Circuit Breaker Protection
Automatic protection against external API failures
import CostLens from 'costlens';
import OpenAI from 'openai';
const costlens = new CostLens({
apiKey: process.env.COSTLENS_KEY
});
// Wrap once
const openai = costlens.wrapOpenAI(
new OpenAI()
);
// Use normally - savings happen automatically
const result = await openai.chat.completions.create({
model: 'gpt-4',
messages: [...]
});
// ✅ Routed to GPT-3.5 (20x cheaper)
// ✅ Auth cached for faster responses
// ✅ Circuit breaker active
// ✅ Cost optimized automaticallyPowerful features that automatically reduce your AI spending
Automatically route GPT-4 → GPT-3.5 for simple tasks (20x cheaper). Claude Opus → Haiku for basic queries (98% savings).
Track costs by prompt, user, and model. See real $ savings, cache hit rates, and export data for reporting.
Tag prompts by feature, user, or use case. Perfect for cost attribution and understanding which features cost the most.
Comprehensive analytics and cost attribution that actually helps you optimize spending
Track costs by prompt ID, user, model, and provider. Know exactly which features or users drive your AI spending.
See actual $ saved from smart routing, cache hits, and optimizations. Export data for budget reports and ROI analysis.
Monitor success rates, latency, and quality scores. Identify which models work best for different use cases.
📊 Cost Analytics Dashboard 💰 Total Saved This Month: $1,247 📈 Smart Routing Savings: $892 (71%) 🔄 Cache Hit Savings: $355 (29%) 📋 Top Cost Drivers: • code-review: $234 (18.7%) • customer-support: $189 (15.1%) • content-generation: $156 (12.5%) 🤖 Model Performance: • GPT-4 → GPT-3.5: 847 routes (avg 94% quality) • Claude Opus → Sonnet: 234 routes (avg 91% quality) 📊 Export to CSV for budget reports
Pay only when you're saving money
Practical guides and strategies from our team