Get CostLens running in your project in 2 minutes.
npm install costlensGo to Settings → API Keys and create a key. Add it to your environment:
.env
COSTLENS_API_KEY=cl_your_key_hereapp.ts
import { CostLens } from 'costlens'
import OpenAI from 'openai'
const costlens = new CostLens({
apiKey: process.env.COSTLENS_API_KEY
})
// Wrap once
const openai = costlens.wrapOpenAI(new OpenAI())
// Use exactly like normal — tracking is automatic
const result = await openai.chat.completions.create({
model: 'gpt-5.4',
messages: [{ role: 'user', content: 'Summarize this document' }]
})That's it. Every request is now tracked with cost, tokens, latency, and model used.
Add tags to attribute costs to specific features or users:
app.ts
const result = await openai.chat.completions.create({
model: 'gpt-5.4',
messages: [{ role: 'user', content: 'Review this PR' }]
}, {
promptId: 'code-review', // Track by feature
userId: 'dev_alice', // Track by developer
})View per-developer and per-feature breakdowns in Analytics.
A workspace is created automatically when you sign up. Invite team members from Settings → Team.
Owner — full access, billing, invite/remove members
Admin — manage settings and API keys
Member — view dashboard and analytics
Each member's API calls are automatically attributed to them in the analytics dashboard.
Configure alerts in Settings → Alerts:
Cost spike — alert when daily spend exceeds a threshold
Error rate — alert when failure rate exceeds a percentage
Slow response — alert when latency exceeds a threshold
Receive budget alerts in your Slack channel:
https://hooks.slack.com/services/...)CostLens can automatically route simple prompts to cheaper models:
app.ts
const costlens = new CostLens({
apiKey: process.env.COSTLENS_API_KEY,
smartRouting: true, // Route simple prompts to cheaper models
enableCache: true, // Cache repeated requests
costLimit: 0.10, // Max $0.10 per request
})Configure routing strategy and quality thresholds in Settings → Routing.