@cwillam/pi-minimax-usage

Pi extension: live MiniMax Token Plan usage (5h + weekly) in the status bar. Not affiliated with MiniMax Inc.

Packages

Package details

extension

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

$ pi install npm:@cwillam/pi-minimax-usage
Package
@cwillam/pi-minimax-usage
Version
1.0.1
Published
Sep 9, 2026
Downloads
255/mo · 255/wk
Author
cwillam
License
MIT
Types
extension
Size
18.8 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

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

README

pi-minimax-usage

Pi extension that puts your MiniMax Token Plan usage in the status bar.

MiniMax 5h●43% ↺3h12m  wk●12% ↺4d8h

Two windows: the 5-hour rolling quota and the weekly quota, each as used-percent with a reset countdown. Colour shifts at 70 % (yellow) and 90 % (red). The block vanishes when you switch away from MiniMax.

Not affiliated with, endorsed by, or sponsored by MiniMax Inc. "MiniMax" is a trademark of MiniMax Inc. This extension only reads the publicly documented quota endpoint.

Install

pi install npm:@cwillam/pi-minimax-usage

Make sure the minimax provider is configured in pi (API key available). Restart Pi, switch to a MiniMax model, the block shows up in the footer within about a second.

Slash command

/minimax-usage           show current snapshot
/minimax-usage refresh   force-poll now
/minimax-usage help      command help

Settings

Optional, under minimaxUsage in ~/.pi/agent/settings.json:

{
  "minimaxUsage": {
    "refreshIntervalMs": 30000,   // min 5000, default 60000
    "host": "global",             // "global" or "cn"
    "endpoint": "https://www.minimax.io/v1/token_plan/remains"  // overrides host, must be on the allowlist
  }
}

The endpoint setting only accepts the two documented MiniMax URLs (exact match). Anything else is ignored, falls back to host.

How it works

On session start or model switch, it grabs the API key for the minimax provider via ctx.modelRegistry.getApiKeyForProvider() and polls GET /v1/token_plan/remains every refreshIntervalMs. The response's general bucket gives two *_remaining_percent fields (5h + weekly); the extension inverts them to consumed-% and paints the footer.

Wire-format details the parser handles:

  • HTTP 200 even on auth failure — the real code lives in base_resp.status_code (1004 = no key, 2049 = wrong host)
  • The *_remaining_percent fields are remaining, not consumed — inverted to match the rest of the app
  • Timestamps are epoch milliseconds, not seconds
  • Only the general bucket is shown; video/other buckets are ignored

Troubleshooting

Symptom Cause Fix
MiniMax no api key No credential for minimax provider Configure it like any other pi provider
MiniMax 1004 or MiniMax invalid key Key rejected for this host Flip host between global / cn, or set endpoint to the matching URL
Block doesn't appear Active provider isn't minimax Check with /model
Stale data after model switch Cached state cleared on switch Next poll (~1 s) repopulates it

Run /minimax-usage to see the current snapshot, error, and last-poll timestamp.

Credits

Wire-format field names came from ai-usagebar (Rust). Architectural pattern borrowed from @d3ara1n/pi-usage-block.

License

MIT — see LICENSE.