Install
openclaw skills install xai-prepaid-monitorMonitor xAI prepaid credit balance with a reusable Python script and alert workflow. Use when setting up or troubleshooting low-credit checks for xAI/Grok usage, building cron jobs that warn on prepaid balance thresholds, or creating follow-up automations such as Discord alerts or task creation when xAI credits run low.
openclaw skills install xai-prepaid-monitorUse this skill to add a reusable xAI prepaid balance check to an OpenClaw setup.
scripts/check_xai_balance.py, a small script that queries the xAI Management API and returns normalized JSONSet these env vars in OpenClaw config or the runtime environment before using the script:
XAI_TEAM_IDXAI_MANAGEMENT_KEYOptional thresholds:
XAI_BALANCE_WARN_BELOW_CENTS (default 300)XAI_BALANCE_CRITICAL_BELOW_CENTS (default 200)Use:
/usr/bin/python3 /path/to/skills/xai-prepaid-monitor/scripts/check_xai_balance.py
The script prints JSON like:
{
"ok": true,
"status": "warn",
"total_cents": 700,
"used_cents": 450,
"remaining_cents": 250,
"total": "$7.00",
"used": "$4.50",
"remaining": "$2.50",
"warn_below": "$3.00",
"critical_below": "$2.00",
"billing_cycle": "..."
}
Interpret the result this way:
ok=false: the check failed, surface the error brieflystatus=ok: no action neededstatus=warn: remaining balance is below warning thresholdstatus=critical: remaining balance is below critical thresholdexecok=false, send a short failure alertstatus=ok, stay quiet or log successstatus=warn or critical, send a concise alertFor prompt patterns, read:
references/cron-examples.md