CostCanary — LLM Cost Linter for VS Code
Detects LLM calls in your code, shows inline cost annotations, and offers one-click fixes to reduce spend.

What it does
- Inline cost annotations above every LLM call:
🐦 🟢 ~$0.003/call · 847 calls/30d · "chat"
- Squiggly-line diagnostics for untracked calls, missing
userId, exceeded cost thresholds, and placeholder values
- Quick Fixes (Cmd+.) to wrap calls with
track(), add userId, or switch to a cheaper model
- Model autocomplete with pricing as you type inside
model: "..." or model="..."
- Save-time warnings when a file has untracked expensive calls (configurable: off/warn/block)
- Status bar showing the per-file cost estimate for the active document
- Sidebar with three panels: Features (cost by feature), Savings (model downgrade recommendations), Alerts
How it works
CostCanary scans your JavaScript, TypeScript, and Python files for LLM API calls using regex pattern matching. It annotates each call with cost data from your CostCanary account (via /api/features). When a cheaper model is available or a call is missing cost tracking, it surfaces a diagnostic and a Quick Fix — no manual configuration required beyond signing in.
Requirements
Quick start
- Install the extension from the VS Code Marketplace
- Open the Command Palette (Cmd+Shift+P) and run CostCanary: Sign In
- Paste your API key from costcanary.dev/settings
- Open any JS/TS/Python file that makes LLM API calls — cost annotations appear automatically
Detected patterns
JavaScript / TypeScript
track({ feature: "...", userId, fn }) — CostCanary SDK
wrapClient(client, { ... }) — CostCanary SDK
client.chat.completions.create(...) — OpenAI
client.responses.create(...) — OpenAI
client.embeddings.create(...) — OpenAI
client.images.generate(...) — OpenAI
client.messages.create(...) — Anthropic
model.generateContent(...) — Google Generative AI
Python
client.chat.completions.create(model="...") — OpenAI
client.messages.create(model="...") — Anthropic
model.generate_content(...) — Google Generative AI
ChatOpenAI(...), ChatAnthropic(...) — LangChain
OpenAI(model="...") — LlamaIndex
client.chat(model="...") — Mistral
Diagnostics
| Code |
Severity |
Description |
costcanary.untrackedCall |
Info |
LLM call not wrapped in track() or wrapClient() |
costcanary.missingUserId |
Warning |
track() call has no userId — costs appear as anonymous |
costcanary.placeholderUserId |
Warning |
userId contains a TODO placeholder — replace before shipping |
costcanary.thresholdExceeded |
Warning |
Feature cost exceeds your configured critical threshold |
All diagnostics except placeholderUserId can be dismissed per-file via Dismiss for this file in the Quick Fix menu, or reset globally with CostCanary: Reset All Dismissals from the Command Palette.
Configuration
| Setting |
Type |
Default |
Description |
costcanary.apiUrl |
string |
http://localhost:3000 |
CostCanary API base URL |
costcanary.thresholdWarning |
number |
0.01 |
Cost per call (USD) that triggers a yellow 🟡 warning |
costcanary.thresholdCritical |
number |
0.05 |
Cost per call (USD) that triggers a red 🔴 critical indicator |
costcanary.preCommitCheck |
string |
"warn" |
Save-time check: "off", "warn", or "block" |
costcanary.showCodeLens |
boolean |
true |
Show inline cost annotations above LLM calls |
costcanary.showStatusBar |
boolean |
true |
Show per-file cost estimate in the status bar |
Keyboard shortcuts
| Action |
Shortcut |
| Show Quick Fixes |
Cmd+. (Mac) / Ctrl+. (Win/Linux) |
| Reset all dismissals |
Cmd+Shift+Alt+D (Mac) / Ctrl+Shift+Alt+D (Win/Linux) |
Quick Fixes are standard VS Code code actions — they appear via the lightbulb icon or the keyboard shortcut when the cursor is on a diagnostic.
Commands (Command Palette)
| Command |
Description |
| CostCanary: Sign In |
Connect your API key |
| CostCanary: Sign Out |
Disconnect |
| CostCanary: Refresh Data |
Force-refresh all cost data |
| CostCanary: Open Dashboard |
Open costcanary.dev in your browser |
| CostCanary: Reset All Dismissals |
Restore all dismissed diagnostics |
Open the CostCanary activity bar icon to see three panels:
- Features — Tracked features ranked by total cost, with cost-per-call, call volume, and % of bill
- Savings — Model downgrade recommendations from the API, with estimated monthly savings. Session fixes are shown in the header.
- Alerts — Configured alert rules and recent trigger history
Troubleshooting
Annotations don't appear
- Confirm you are signed in: run CostCanary: Sign In from the Command Palette
- Check that
costcanary.showCodeLens is true in settings
- Annotations only appear on files with detected LLM calls
"No cost data yet" for a feature
- Data appears after events are ingested by the SDK. Call
track() in production and wait for the next ingest cycle.
The model switch Quick Fix replaced the wrong text
Dismissed diagnostics won't come back
- Run CostCanary: Reset All Dismissals from the Command Palette to restore all diagnostics.
Extension shows stale data
- Run CostCanary: Refresh Data to force a re-fetch from the API.
Links