@alexanderfortin/pi-zai-usage

Pi extension for monitoring Z.ai API token usage quota

Package details

extension

Install @alexanderfortin/pi-zai-usage from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@alexanderfortin/pi-zai-usage
Package
@alexanderfortin/pi-zai-usage
Version
0.1.11
Published
May 4, 2026
Downloads
1,265/mo · 117/wk
Author
alexanderfortin
License
MIT
Types
extension
Size
23.4 KB
Dependencies
3 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./dist/index.js"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

Pi coding agent Z.ai Usage Extension

codecov

A Pi coding agent extension that monitors Z.ai subscription API token usage quota and automatically displays usage in the footer when using the Z.ai provider.

screenshot

Features

  • Auto Footer Display: Automatically shows usage in the footer when using Z.ai models
  • Smart Caching: Caches usage data for 30 seconds to avoid excessive API calls
  • Time Tracking: Displays remaining time until quota reset

Install

pi install npm:@alexanderfortin/pi-zai-usage

or

pi install https://github.com/shaftoe/pi-zai-usage

or if you prefer to build and keep it checked out locally:

git clone https://github.com/shaftoe/pi-zai-usage
cd pi-zai-usage

# Install dependencies
bun install

# Build the extension
bun run build

# Install the extension
pi install ./

Development

This project uses modern TypeScript development tooling:

  • Bun - Fast package manager and runtime
  • TypeScript 6 - Static type checking with strict mode enabled
  • Biome - Ultra-fast linter and formatter
# Type check
bun run typecheck

# Lint code
bun run lint

# Auto-fix lint issues
bun run lint:fix

# Format code
bun run format

# Run all checks
bun run check

# Watch mode for development
bun run dev

Usage

Automatic Footer Display

When using a Z.ai model (e.g., glm-4.7, glm-5, glm-5-flash), the extension automatically displays the usage in the footer (between brackets the time left for the quota to be reset):

Z.ai: 45% (2h 15m 30s)

The footer updates after each AI turn and on model selection changes.

Configuration

No configuration needed. The extension automatically:

  • Uses cached data for 30 seconds to avoid excessive API calls
  • Shows/updates status only when Z.ai models are active
  • Clears status when switching to non-Z.ai models

API

The extension uses the Z.ai API endpoint: https://api.z.ai/api/monitor/usage/quota/limit

Make sure you're logged in to Z.ai via Pi (/login for Z.ai).

Releasing

This project uses automated publishing to NPM via GitHub Actions. The workflow will:

  • Run all CI checks
  • Build the package
  • Publish to NPM with provenance (signed) via trusted publishing

License

MIT