Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>CodeSpendNew to Visual Studio Code? Get it now.
CodeSpend

CodeSpend

dev2code

|
2 installs
| (1) | Free
A local-first VS Code dashboard for coding activity and opt-in AI API usage analytics.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CodeSpend

CodeSpend is a local-first VS Code extension for tracking coding time and opt-in AI API usage.

It helps you see:

  • Coding time and recent editor activity
  • Language and file activity
  • AI API requests, tokens, models, providers, and estimated cost
  • Provider/model filtered graphs for AI usage

CodeSpend is currently focused on the free local dashboard experience.

Open the Dashboard

Use the VS Code Command Palette:

CodeSpend: Open Data View

The dashboard has two main modes:

  • Coding Time: coding time, language usage, writes, and recent activity
  • AI Usage: API requests, tokens, cost, provider filters, model filters, and graphs

Use CodeSpend: Refresh when you want to manually reload the latest local data.

Coding Time

Coding activity starts automatically when the extension is active.

The Coding Time view shows:

  • Coding time today
  • Current active session
  • Top language
  • Activity events
  • File writes
  • Recent local activity

CodeSpend stores this activity locally.

AI API Usage Tracking

AI usage tracking is opt-in. To track AI API usage, you need to route API calls through a CodeSpend tracked VS Code terminal.

Supported providers:

  • OpenAI
  • Anthropic
  • OpenRouter
  • Custom OpenAI-compatible provider

Save Provider API Keys

Use the VS Code Command Palette:

CodeSpend: Manage API Keys

Choose a provider and paste your real provider API key.

Keys are stored in VS Code SecretStorage. After saving a key, new tracked terminals receive the correct provider environment variable, such as:

OPENROUTER_API_KEY
OPENAI_API_KEY
ANTHROPIC_API_KEY
CUSTOM_PROVIDER_API_KEY

For saved keys, these terminal variables contain a local CodeSpend routing token, not the raw provider key. CodeSpend uses that local token to retrieve the real provider key from VS Code SecretStorage only when forwarding the request.

Open a Tracked Terminal

Use:

CodeSpend: Open Tracked Terminal

This opens a VS Code terminal with routed base URLs and local routing tokens for any saved provider keys.

For OpenRouter, you should see:

echo "$OPENROUTER_BASE_URL"
test -n "$OPENROUTER_API_KEY" && echo "OpenRouter key is set"

The base URL should point to CodeSpend’s local tracking route. The provider key variable should be set, but for saved keys it should contain a local CodeSpend token instead of the raw provider key.

Enable No-Code Terminal Tracking

Use:

CodeSpend: Manage API Usage Tracking

Then choose:

Enable No-Code Terminal Tracking

This applies environment variables to new VS Code terminals automatically.

Important:

  • Existing terminals must be restarted.
  • New VS Code terminals will get local routing tokens for saved provider keys.
  • Outside a VS Code terminal, it will not automatically work unless you manually export the same environment variables.
  • Any process you run in a tracked terminal can read that terminal's environment variables, so only run trusted scripts there.

Run API Calls

Example OpenRouter request:

curl "$OPENROUTER_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "poolside/laguna-m.1:free",
    "messages": [
      { "role": "user", "content": "Say hello from Laguna." }
    ]
  }'

After the request completes, open the dashboard and switch to AI Usage.

Use With Scripts

Scripts work when run inside a tracked VS Code terminal.

Example:

node script.js
python script.py
npm run dev

Your script should use the normal provider env vars.

Example JavaScript with OpenRouter:

const response = await fetch(`${process.env.OPENROUTER_BASE_URL}/chat/completions`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'poolside/laguna-m.1:free',
    messages: [{ role: 'user', content: 'Say hello from Laguna.' }]
  })
});

console.log(await response.json());

Example with the OpenAI SDK and OpenRouter:

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.OPENROUTER_API_KEY,
  baseURL: process.env.OPENROUTER_BASE_URL
});

const completion = await client.chat.completions.create({
  model: 'poolside/laguna-m.1:free',
  messages: [{ role: 'user', content: 'Say hello from Laguna.' }]
});

console.log(completion.choices[0].message.content);

Provider and Model Filters

In the AI Usage dashboard:

  • Select a provider to see only that provider’s data.
  • Select a model to focus on one model.
  • Keep All Models selected to compare multiple models in the same graph.

When multiple models are shown, each model gets its own line and legend color.

Custom Provider

For an OpenAI-compatible custom provider:

  1. Set codespend.customProviderName in VS Code settings.
  2. Set codespend.customProviderBaseUrl in VS Code settings.
  3. Save the custom provider key with CodeSpend: Manage API Keys.
  4. Use CodeSpend: Open Tracked Terminal.

The tracked terminal exposes:

CUSTOM_PROVIDER_BASE_URL
CUSTOM_PROVIDER_API_KEY

Troubleshooting

If the dashboard does not show AI usage:

  • Make sure the request was run from a tracked VS Code terminal.
  • Restart existing terminals after enabling no-code terminal tracking.
  • Confirm the routed base URL is being used.
  • Confirm your provider API key is present.
  • Refresh the CodeSpend dashboard manually.

For OpenRouter:

echo "$OPENROUTER_BASE_URL"
test -n "$OPENROUTER_API_KEY" && echo "OpenRouter key is set"

If the API key is missing, run:

CodeSpend: Manage API Keys

Then open a new tracked terminal.

Privacy

CodeSpend is designed around local visibility.

AI tracking records usage metadata such as provider, model, token counts, request counts, and estimated cost. Prompts and responses are not shown in the dashboard.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft