Loading...
Loading...
Everything you need to integrate CostLens and start saving money on AI costs with automatic optimization.
Wrap your client once, tracking happens automatically
Save 20-40% on API costs with smart routing and intelligent caching
Built-in exponential backoff for failed requests
Batch Processing: 3-5x faster with reduced HTTP overhead
Smart Caching: 90% faster authentication with 5-minute cache
Circuit Breaker: 99.9% uptime with automatic failure protection
Smart Routing: Automatic task detection and optimal model selection
Track GPT-4, GPT-4o, GPT-3.5, and other OpenAI models with automatic cost calculation
Track Claude 3 Opus, Sonnet, and Haiku with real-time analytics
Get 3-5x better performance with batch processing, smart caching, and circuit breaker protection
Wrap your client and get automatic tracking:
import { CostLens } from 'costlens';
import OpenAI from 'openai';
const openai = new OpenAI();
const costlens = new CostLens({
apiKey: process.env.COSTLENS_API_KEY,
enableCache: true, // Optional: enable caching
maxRetries: 3 // Optional: auto-retry
});
// Wrap once
const tracked = costlens.wrapOpenAI(openai);
// Use normally - tracking happens automatically!
const result = await tracked.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello!' }]
});