Record and check package-defined usage metrics through the aux4 Billing API. Metric keys and labels come from the calling package's plans.json; this package does not interpret their meaning.
aux4 aux4 pkger install aux4/meter
Package code supplies only the metric key. aux4 supplies the calling package identity, the active CLI session supplies the access token, and Billing selects the single entitled buyer scope:
aux4 metric record clown-fish
aux4 metric check clown-fish
Recorded 1 clown-fish
Clown fish: 7/10
Use --quantity to consume more than one unit and --idempotencyKey when retrying the same logical use:
aux4 metric record clown-fish --quantity 2 --idempotencyKey request-8cda2
Use JSON output when package logic needs the exact values:
aux4 metric check clown-fish --json true
record is the authoritative consume operation. Billing verifies the entitlement and atomically increments only when the active plan has enough capacity. If the request would exceed a finite limit, it fails without changing usage. Packages therefore call record once immediately before granting the feature. check remains a read-only status/preflight command and exits with status 2 when the allowance is exhausted.
AUX4_METRIC_SCOPE — optional buyer-scope override. Set it only when the authenticated user has more than one scope entitled to the same package.AUX4_METRIC_PACKAGE — optional calling-package override as <scope>/<name> for direct invocation or development. Nested package calls receive this context automatically.AUX4_ACCESS_TOKEN — caller bearer token. When absent, the active aux4 session is used.AUX4_BILLING_API_URL — optional Billing API base URL override. By default, a dev SSO session uses the dev Billing API and all other sessions use production. Overrides must use HTTPS, except loopback HTTP for local development.