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
Reduce API costs by up to 80% with intelligent caching
Built-in exponential backoff for failed requests
Custom Routing Policy: Override routing decisions with custom logic
Quality Validation: Implement custom quality scoring
Request Correlation: Track related requests with correlation IDs
Enhanced Analytics: Better tracking and correlation capabilities
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!' }]
});