Live quota inspector for CPA management APIs.
This project queries real quota windows from a running CPA instance and renders a terminal report with plan-aware sorting, status coloring, and quota bar visualization.
- Uses live data from CPA management routes instead of offline estimation.
- Shows account-level
code 5handcode 7dquota windows. - Aggregates equivalent quota percentages per plan (
free,plus). - Supports progress display while querying many auth files.
The tool mirrors CPA management flow for currently supported providers:
GET /v0/management/auth-filesPOST /v0/management/api-call- CPA forwards upstream request to
https://chatgpt.com/backend-api/wham/usage
Status is derived from code-7d remaining percentage:
0->exhausted0-30->low30-70->medium70-100->high100->full
- Static report output (default) with colored plan and status.
- Terminal-width adaptive table layout.
- Unicode gradient quota bars with
--ascii-barsfallback. - Optional real-time fetch progress with current auth file name.
- JSON mode for automation.
- Retry for transient query failures.
- Go
1.25+ - Running CPA service
- CPA management key (if enabled)
go build -o cpa-quota-inspector ../cpa-quota-inspector -k YOUR_MANAGEMENT_KEY--cpa-base-url: CPA base URL--management-key,-k: management bearer key--concurrency: concurrent quota workers--timeout: HTTP timeout seconds--retry-attempts: transient retry count--version: print version/build metadata--filter-plan: filter byplan_type--filter-status: filter by status--json: print JSON payload--plain: plain text output--summary-only: summary only--ascii-bars: ASCII quota bars instead of Unicode bars--no-progress: disable fetch progress line
JSON output:
./cpa-quota-inspector \
--json \
--cpa-base-url http://127.0.0.1:8317 \
-k YOUR_MANAGEMENT_KEYDisable progress line:
./cpa-quota-inspector \
--no-progress \
--cpa-base-url http://127.0.0.1:8317 \
-k YOUR_MANAGEMENT_KEYASCII bars:
./cpa-quota-inspector \
--ascii-bars \
--cpa-base-url http://127.0.0.1:8317 \
-k YOUR_MANAGEMENT_KEYPrint version metadata:
./cpa-quota-inspector --version- Default order: plan rank (
free,team,plus, others) then ascendingcode-7dremaining. - Summary includes:
plan_countsstatus_countsfree_equivalent_7dplus_equivalent_7d
main.go: CLI entrypoint and orchestrationtypes.go: constants and data modelsfetch.go: API calls, parsing, status derivationrender.go: terminal report renderinghelpers.go: shared helpers and formatting utilities
Format and test:
gofmt -w *.go
go test ./...Create and push a semantic tag:
git checkout main
git pull
git tag -a v0.1.0 -m "v0.1.0"
git push origin v0.1.0Build multi-platform artifacts with GoReleaser:
goreleaser release --clean- Code review quota is intentionally not displayed.
