Skip to content

CruiseDevice/Z.ai-usage-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Z.ai Usage Tracker

A Visual Studio Code extension that displays your Z.ai API usage directly in the status bar. Keep track of your token usage, weekly quota, and MCP usage at a glance without leaving your editor.

Features

  • Status Bar Display – Shows your Z.ai usage percentage with color-coded indicators
  • Detailed Tooltip – Hover to see:
    • 5h token usage with progress bar
    • Weekly quota usage
    • MCP usage count
    • Time remaining until quota reset
    • Current plan level
  • Manual Refresh – Click the status bar item or use the command palette to refresh usage data
  • API Key Management – Securely configure your Z.ai API key through VS Code settings or environment variables
  • Color Indicators – Visual feedback based on usage level:
    • < 50%: Green
    • 50-75%: Yellow
    • 75-90%: Orange
    • 90%+: Red

Installation

Method 1: Install from Folder (Recommended)

  1. Clone or download this repository
  2. Open VS Code and press F1 or Ctrl+Shift+P (or Cmd+Shift+P on macOS) to open the Command Palette
  3. Type Install from VSIX and select it
  4. Navigate to the cloned folder and select the .vsix file

Note: If you don't have a .vsix file yet, you'll need to build the extension first (see Building from Source).

Method 2: Install Extension via Location

  1. Clone or download this repository to your local machine
  2. Open VS Code and press F1 or Ctrl+Shift+P (or Cmd+Shift+P on macOS)
  3. Type Extensions: Install Extensions from Location... and select it
  4. Navigate to and select the folder containing the extension (the folder with package.json)
  5. VS Code will install the extension directly from the folder

Tip: This method installs the extension in development mode. You can also press F5 in the extension folder to launch a new VS Code window with the extension loaded for testing.

Method 3: Building from Source

If you want to build the extension yourself:

  1. Install Node.js dependencies:

    npm install
  2. Compile the TypeScript code:

    npm run compile
  3. (Optional) Package the extension as a .vsix file:

    npm install -g @vscode/vsce
    vsce package

Then follow Method 1 or Method 2 above.

Configuration

The extension can be configured through VS Code settings (settings.json) or the Settings UI.

Settings

Setting Type Default Description
zaiUsage.refreshInterval number 60 Refresh interval in seconds
zaiUsage.notifications.enabled boolean true Show notifications when approaching limits
zaiUsage.notifications.thresholds array [75, 90, 95] Percentage thresholds for notifications
zaiUsage.apiKey string "" Z.ai API key (or use ZAI_API_KEY env var)

API Key Setup

You can provide your Z.ai API key in two ways:

  1. Via Settings – Set zaiUsage.apiKey in your settings
  2. Via Environment Variable – Set the ZAI_API_KEY environment variable
  3. Via Command – Run the Z.ai Usage: Configure command from the Command Palette

Commands

Command ID Description
Z.ai Usage: Refresh zaiUsage.refresh Manually refresh usage data
Z.ai Usage: Configure zaiUsage.configure Set up your Z.ai API key
Z.ai Usage: Copy Usage (JSON) zaiUsage.copyJson Copy current usage as JSON

Requirements

  • Visual Studio Code 1.85.0 or higher
  • Z.ai API key

License

MIT

Development

  • Run npm run compile to compile the TypeScript code
  • Run npm run watch to watch for changes and recompile automatically
  • Press F5 in VS Code to launch a new Extension Development Host window with the extension loaded

About

A Visual Studio Code extension that displays your Z.ai API usage directly in the status bar. Keep track of your token usage, weekly quota, and MCP usage at a glance without leaving your editor.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors