AI Cost Lens
Track AI API costs in real-time directly in VS Code. See spend per model, set budget alerts, and never be surprised by your AI bill.
Features
- Status Bar Tracker — See today's spend at a glance with color-coded budget status (green/yellow/red)
- Output Channel Auto-Detection — Automatically parses AI usage from VS Code output channels (OpenAI, Anthropic, Google, and more)
- Cost Dashboard — Sidebar panel showing daily/weekly/monthly breakdowns by model and provider
- Budget Alerts — Set daily, weekly, and monthly limits with configurable warning thresholds
- Manual Logging — Log costs manually via the command palette when auto-detection isn't available
- CSV Export — Export your cost history for reporting and analysis
Supported Providers & Models
| Provider |
Models |
| OpenAI |
gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-4-turbo, o1, o3-mini |
| Anthropic |
claude-opus-4, claude-sonnet-4, claude-haiku-4.5, claude-haiku-3.5 |
| Google |
gemini-2.5-pro, gemini-2.5-flash, gemini-2.0-flash, gemini-1.5-pro |
| AWS Bedrock |
claude-3-sonnet-bedrock, titan-text-express, llama-3-70b-bedrock |
| Mistral |
mistral-large, mistral-small |
21 models across 5 providers. Model aliases are supported (e.g., claude-3.5-sonnet resolves to claude-sonnet-4).
Installation
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X)
- Search for "AI Cost Lens"
- Click Install
Usage
Auto-Detection
AI Cost Lens automatically monitors VS Code output channels for token usage patterns. When an AI tool logs usage data (JSON or key-value format), costs are captured automatically.
Supported log formats:
{"prompt_tokens": 150, "completion_tokens": 50, "model": "gpt-4o"}
model: claude-sonnet-4, input_tokens: 1200, output_tokens: 300
Tokens used: 500 input, 200 output (gpt-4o-mini)
Manual Logging
- Open the Command Palette (
Ctrl+Shift+P)
- Run "AI Cost Lens: Log Cost"
- Select the model, enter input and output token counts
Dashboard
Click the AI Cost Lens icon in the activity bar (left sidebar) to open the cost dashboard showing:
- Today's total spend with budget progress bar
- Cost breakdown by model
- Input/output token totals
Export
Run "AI Cost Lens: Export Cost Report" from the command palette to save your cost history as a CSV file.
Configuration
| Setting |
Default |
Description |
aiCostLens.dailyBudget |
10.00 |
Daily budget limit in USD |
aiCostLens.weeklyBudget |
50.00 |
Weekly budget limit in USD |
aiCostLens.monthlyBudget |
200.00 |
Monthly budget limit in USD |
aiCostLens.showStatusBar |
true |
Show cost tracker in the status bar |
aiCostLens.budgetWarningThreshold |
0.8 |
Warning threshold as fraction of budget (0.0-1.0) |
Commands
| Command |
Description |
AI Cost Lens: Show Dashboard |
Open the cost dashboard sidebar |
AI Cost Lens: Log Cost |
Manually log a cost entry |
AI Cost Lens: Set Budget |
Update your daily budget limit |
AI Cost Lens: Reset Today's Costs |
Clear all cost records |
AI Cost Lens: Export Cost Report |
Export costs to CSV |
How Costs Are Calculated
Costs are calculated using per-token pricing for each model:
cost = (input_tokens / 1,000,000) * input_price + (output_tokens / 1,000,000) * output_price
Pricing data is built into the extension and updated with each release.
License
MIT