Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Account info

meka account usage, whoami and stats expose read-only account information obtained through a provider’s OAuth API, so you can script things that aren’t otherwise reachable (a status bar, a cron alert). Each takes an optional --profile <name> (defaults to the active profile, the way a run does) and a --format plain|json, and reports on the account that profile bills: a request needs a model, which is the profile’s. The requested data goes to stdout; notes and errors go to stderr, so meka account … 2>/dev/null | jq stays clean. The rest of the meka account suite (add, login, list, remove) is documented under Config file.

Availability is per backend: claude-subscription and chatgpt-subscription (subscription OAuth) support these; for usage and stats, API-key backends, OpenAI-compatible endpoints and Ollama print a short “not available” note and exit non-zero. whoami works on any account: it fills the fields it can and fails only when the credential itself is invalid.

meka account usage

Current rate-limit windows (percentage used + reset time):

$ meka account usage
Account usage
  5-hour (session)   [##--------]  23% used  (resets in 1h 58m, 2026-07-02 02:10)
  Weekly             [----------]   4% used  (resets in 12h 48m, 2026-07-02 13:00)

$ meka account usage --format json
{
  "profile": "work",
  "account": "claude-max",
  "windows": [
    { "label": "5-hour (session)", "used_percent": 23.0, "resets_at": 1782958200 },
    { "label": "Weekly", "used_percent": 4.0, "resets_at": 1782997200 }
  ],
  "extra_usage": { "enabled": false, "utilization": null, "used": 0.0,
                   "balance": null, "currency": "USD" },
  "note": null
}

resets_at is a Unix timestamp in seconds (date -d @1782958200). The extra_usage block reports pay-as-you-go / overage state (whether it’s enabled, percent of the extra-usage limit consumed, amount spent, and remaining credit balance); the plain view shows a line when it is enabled, has a balance, or has recorded any spend.

meka account whoami

Account identity, plan, and local auth status. The auth block is computed from the stored credential (no network), so even when the identity call fails because the token needs a re-login, whoami still reports it and exits non-zero:

$ meka account whoami
account:       claude-max
backend:       claude-subscription
profile:       work
auth:          valid (5h 45m)
plan:          claude_max
tier:          default_claude_max_20x
subscription:  active
role:          admin

$ meka account whoami --format json
{
  "profile": "work",
  "account": "claude-max",
  "backend": "claude-subscription",
  "auth": { "valid": true, "expires_at": 1782971829, "expires_in_seconds": 20709 },
  "identity": { "plan": "claude_max", "tier": "default_claude_max_20x",
                "subscription_status": "active", "role": "admin", ... }
}

identity is null when the backend has no identity endpoint. expires_at / expires_in_seconds are in seconds; a negative expires_in_seconds (or valid: false) means “run meka account login”.

meka account stats

Historical usage. chatgpt-subscription is rich (lifetime tokens, peak day, streaks, and per-day token counts); claude-subscription reports only a first-used date:

$ meka account stats
account:     claude-max
profile:     work
first used:  2026-04-01

$ meka account stats --format json
{ "profile": "work", "account": "claude-max", "lifetime_tokens": null, "peak_daily_tokens": null,
  "current_streak_days": null, "longest_streak_days": null,
  "first_used": "2026-04-01T17:36:16.996974Z", "daily": [] }

For Codex, daily is a list of { "date": "YYYY-MM-DD", "tokens": N } you can feed into a graph.

Example: i3blocks

A block that shows the Claude 5-hour and weekly usage, refreshed every 5 minutes:

#!/bin/sh
# ~/.config/i3blocks/meka-usage   (set interval=300)
u=$(meka account usage --profile work --format json 2>/dev/null) || { echo "claude ?"; exit 0; }
echo "$u" | jq -r '
  (.windows[] | select(.label|startswith("5-hour")).used_percent) as $s |
  (.windows[] | select(.label=="Weekly").used_percent) as $w |
  "claude 5h:\($s|floor)% wk:\($w|floor)%"'

Each invocation makes one API call, so keep the poll interval sane (minutes, not seconds). The token is refreshed automatically when near expiry and written back to the store, exactly as during a normal session.