← 返回
未分类 Key 中文

xAI Prepaid Monitor

Monitor xAI prepaid credit balance with a reusable Python script and alert workflow. Use when setting up or troubleshooting low-credit checks for xAI/Grok us...
使用可复用的 Python 脚本监控 xAI 预付费信用余额,并配合警报工作流。适用于在设置或排查 xAI/Grok 低额度检查时使用。
therealmrb123 therealmrb123 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 225
下载
💾 0
安装
1
版本
#latest

概述

Use this skill to add a reusable xAI prepaid balance check to an OpenClaw setup.

What this skill provides

  • scripts/check_xai_balance.py, a small script that queries the xAI Management API and returns normalized JSON
  • a reference file with cron prompt patterns for:
  • alert-only monitoring
  • alert + follow-up task creation

Environment required

Set these env vars in OpenClaw config or the runtime environment before using the script:

  • XAI_TEAM_ID
  • XAI_MANAGEMENT_KEY

Optional thresholds:

  • XAI_BALANCE_WARN_BELOW_CENTS (default 300)
  • XAI_BALANCE_CRITICAL_BELOW_CENTS (default 200)

Run the script

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": "..."
}

Output contract

Interpret the result this way:

  • ok=false: the check failed, surface the error briefly
  • status=ok: no action needed
  • status=warn: remaining balance is below warning threshold
  • status=critical: remaining balance is below critical threshold

Recommended workflow

  1. Run the script with exec
  2. Parse the JSON output
  3. If ok=false, send a short failure alert
  4. If status=ok, stay quiet or log success
  5. If status=warn or critical, send a concise alert
  6. Optionally create a follow-up task in the user’s task system

Cron setup

For prompt patterns, read:

  • references/cron-examples.md

Guardrails

  • Keep delivery logic separate from the script. The script should only fetch and normalize balance data.
  • Do not hard-code Discord channel IDs, Todoist paths, or user-specific routing into the script.
  • Prefer environment variables for thresholds so the same script works across setups.
  • If the xAI API contract changes, update the script and the examples together.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-21 15:27 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

Tmux

steipete
通过发送按键和抓取窗格输出,远程控制交互式 CLI 的 tmux 会话。
★ 46 📥 29,539
it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,915
it-ops-security

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,639