Skip to content
| Marketplace
Sign in
Visual Studio Code>Visualization>TokenGuardNew to Visual Studio Code? Get it now.
TokenGuard

TokenGuard

Aditya Gupta

|
1 install
| (1) | Free
Track GitHub Copilot AI credits, token usage, and costs across your projects
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

TokenGuard - VS Code Extension

Passively track GitHub Copilot AI credits, token usage, and costs directly inside VS Code. No workflow changes required; just install and it monitors your regular Copilot usage in the background.

How It Works

This extension captures token usage by polling Copilot internal Chat's

It parses request metadata (model, prompt_tokens, completion_tokens) and keeps cumulative totals in persistent extension storage. You use Copilot normally; TokenGuard silently tracks everything.

Features

  • Zero-config passive tracking: Works automatically with your regular Copilot usage.
  • All models captured: Claude Opus 4.6/4.7, Sonnet 4.5/4.6, GPT-4o, GPT-5, and more.
  • Actual AI credits tracking: Reads the real copilotUsageAic value from Copilot debug logs (same number shown in Copilot UI).
  • Cost tracking: Shows equivalent USD cost (1 AI credit = $0.01).
  • Input token threshold warnings: Alerts when a request exceeds your configured token limit.
  • Trend-based escalation alerts: Detects when context is growing rapidly and warns before hitting 50K tokens.
  • Request History: Per-request log showing model, tokens, AI credits, and cost.
  • Usage Statistics: Daily, weekly, monthly breakdowns with model aggregation.
  • Per-project breakdown: See which projects consume the most credits.
  • Budget alerts: Notifies when approaching your AI credit budget limit.
  • Dashboard: Visual webview with 30-day bar charts.
  • Export reports: Export data as CSV, JSON, or Markdown.
  • Centralized backend reporting: Optionally sends a daily usage digest to a backend server for org-wide analytics.

AI Credits Tracking

GitHub Copilot bills usage in AI credits (1 credit = $0.01 USD). TokenGuard reads actual credit consumption directly from Copilot debug logs: the same value shown in Copilot Chat UI (for example, Claude Opus 4.6 · 15.7 credits).

The sidebar shows:

  • AI Credits (Today/Month): Actual credits consumed.
  • Cost (Today/Month): Equivalent USD (credits × $0.01).

Budget tracking defaults to 1,900 credits/month (Copilot Business per-user allowance). Adjust via TokenGuard.budgetLimit.

Plan Allowances (Reference)

Plan Credits/Month
Copilot Pro 1,500
Copilot Pro+ 7,000
Copilot Max 20,000
Copilot Business 1,900/user (pooled)
Copilot Enterprise 3,900/user (pooled)

Context Size Warnings

TokenGuard proactively helps manage context costs.

Per-Request Threshold

When any Copilot request exceeds your configured token threshold (default: 8,000), TokenGuard shows a warning with token count, model, and cost. Adjust via TokenGuard.inputTokenWarningThreshold.

Trend-Based Escalation

TokenGuard tracks a sliding window of your last 5 requests:

  • Growth warning: Context doubled and latest request is over 30K tokens.
  • Escalation alert (modal): Projected next request is over 50K tokens.

This helps you know when to start a fresh chat before costs spiral.

Context Reset and Session Summarization

When input tokens exceed 50K (configurable via TokenGuard.contextResetThreshold), TokenGuard offers:

  1. Summarize and New Chat: Uses the LM API to generate a concise summary from recent chat transcripts. The summary is copied to your clipboard and a new chat opens.
  2. Just Start New Chat: Opens a fresh chat immediately without a summary.

Sidebar Views

The TokenGuard activity bar shows 4 panels:

  1. Usage Summary: Token counts (with input/output breakdown), largest context size today, AI credits consumed, and cost.
  2. Request History: Last 200 requests in a 3-level tree (dates → prompts → sub-requests), with model icons, cache %, elapsed time, and expandable sub-request details.
  3. Usage Statistics: Daily (7d), weekly (4w), monthly (3m), and model breakdown.
  4. Per-Project Breakdown: Credit usage by workspace.

Commands

Command Description
TokenGuard: Show Dashboard Open the analytics webview dashboard.
TokenGuard: Set Budget Alert Configure monthly spending limit.
TokenGuard: Export Report Export usage data (CSV/JSON/MD).
TokenGuard: Reset Usage Data Clear all tracked data.
TokenGuard: Refresh Usage (Force Poll) Force immediate poll of Copilot logs.
TokenGuard: Enable/Disable Tracking Toggle tracking on/off.
TokenGuard: Purge Old Data Now Archive entries older than retention period.
TokenGuard: Set Context Reset Threshold Configure context reset token threshold.

Configuration

Setting Default Description
TokenGuard.budgetLimit 1900 Monthly AI credit budget.
TokenGuard.alertThresholdPercent 80 Warning threshold (%).
TokenGuard.inputTokenWarningThreshold 8000 Warn when input tokens exceed this (0 to disable).
TokenGuard.contextResetThreshold 50000 Offer to summarize and reset chat above this.
TokenGuard.defaultModel gpt-4 Default model for cost calculation.
TokenGuard.enabled true Enable/disable all token tracking.
TokenGuard.dataRetentionDays 90 Days to retain raw entries before auto-purging.
TokenGuard.showSubRequests false Store per-sub-request breakdown in history.
TokenGuard.pollIntervalMs 1500 Copilot log poll interval (ms).

Prerequisites

  • GitHub Copilot Chat must be installed and active.
  • Recommended VS Code setting for richer capture:
"github.copilot.chat.debug.requestLogger.maxEntries": 1000

Notes

  • Data source is an internal Copilot debug command; behavior may change between Copilot versions.
  • AI credits are read from copilotUsageAic in Copilot debug export.
  • When copilotUsageAic is unavailable, credits are estimated from token counts × model pricing.
  • Deduplication uses request IDs + log counts to prevent double counting.
  • Usage scope is global per VS Code profile, not per workspace.

Advanced Features

The advanced (paid) version of this extension supports the following additional capabilities:

  • Org-wide analytics dashboard: Centralized backend to aggregate usage across teams and developers.
  • Custom cost models: Define custom pricing tiers for internal chargeback or enterprise billing.
  • Usage policies & enforcement: Set hard limits, auto-disable Copilot at budget cap, or require manager approval.
  • Slack/Teams notifications: Push alerts to team channels when budgets are nearing limits.
  • Historical trend analysis: Long-term trend visualization with anomaly detection.
  • Multi-IDE support: Extend tracking to JetBrains, Neovim, and other Copilot-enabled editors.
  • API access: Programmatic access to usage data for integration with FinOps tools.

For advanced features, enterprise licensing, or custom integrations, please reach out to adiagarwal29@gmail.com.

License

This project is licensed under the MIT License — see the LICENSE file for details.

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