Token导航 LogoToken导航TokenDH.com
开发敏感数据clawhub未标认证来源可访问clear审计提醒

billing-monitor计费监控器

Agent Skill

billing-monitor 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 OpenClaw 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,696

周安装

154

GitHub Stars

公开资料未说明

下载量

1,232
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:billing-monitor(计费监控器)
来源仓库:https://github.com/netanel-abergel/billing-monitor
安装命令:
openclaw skills install billing-monitor
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install billing-monitor

简介

监控 API 计费错误并及时通知管理员与所有者。

  • 适用于高用量服务成本控制与异常支出预警。
  • 自动识别计费异常并触发告警流程。billing-monitor 属于开发类 Skill,可作为该场景下的辅助能力补充。
  • 需配置通知渠道如邮件或即时通讯工具。
  • 建议结合预算阈值设置分级响应策略。适用宿主包括 OpenClaw,接入前应确认版本、权限和运行环境要求。

SKILL.md

name
billing-monitor
description
Monitor for API billing errors and alert the owner and admin immediately. Use when: an API billing error is detected, a peer PA reports a billing error, or during routine health checks. Handles detection, notification, and fallback model switching. Model-agnostic: works with any LLM provider (Anthropic, OpenAI, Google, etc.).

Billing Monitor Skill

Load Local Context

CONTEXT_FILE="/opt/ocana/openclaw/workspace/skills/billing-monitor/.context"
[ -f "$CONTEXT_FILE" ] && source "$CONTEXT_FILE"
# Then use: $OWNER_PHONE, $ADMIN_PHONE, $BILLING_LOG, $BILLING_FALLBACK_CONFIG, etc.

Minimum Model

Any model. Detection and alerting are rule-based. No reasoning required.


When to Run This Skill

Run when you see ANY of these in an API response:

your API key has run out of credits
insufficient balance
billing_error
payment_required
exceeded your current quota
HTTP 402
"type": "billing_error"

When NOT to Alert the Owner

  • Routine billing check completed with no errors → silent, no message
  • HTTP 200 / all clear → silent, no message
  • ElevenLabs 401 (auth, not billing) → silent unless TTS is actively needed

Only alert the owner if:

  1. HTTP 402 detected (out of credits)
  2. LLM is unreachable and the agent cannot function
  3. A peer PA reports a billing error

Routine health checks run silently. The owner does not need a "billing OK" message.

NOTE (Production): Netanel uses a proxy — billing-health-check cron has been REMOVED as not relevant. Only alert on actual API failure detected during real usage.


Response Steps (Run in Order)

Step 1 — Notify Owner

Send via WhatsApp (or preferred channel):

⚠️ Billing issue — I can't respond normally.
My API key ran out of credits (or was rate-limited).
Please top up or switch my API key in agent settings.

Step 2 — Notify Admin

[PA Name] has a billing error.
Owner: [Owner Name]
Action: top up API credits or reassign key.
Time: [current timestamp]

Step 3 — Switch to Fallback Model

  1. Check if config/billing-fallback.json exists
  2. If yes → read the fallback_model field
  3. Run: openclaw config set model "$FALLBACK_MODEL"
  4. If the command fails → tell owner: "Auto-switch failed — please update model manually in agent settings"
  5. Notify owner: "Switched to [Fallback Model] temporarily while primary key is resolved"

If billing-fallback.json doesn't exist → skip this step and tell admin to configure it.

Step 4 — Log the Incident

LOG_DIR="$HOME/.openclaw/workspace/logs"
mkdir -p "$LOG_DIR"

# Append one line to the log file
echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) BILLING_ERROR api_key_exhausted" \
  >> "$LOG_DIR/billing-incidents.log"

Health Check Script

Run this during heartbeat to catch billing issues before they cause failures:

#!/bin/bash
# billing-check.sh
# Checks the LLM provider API key configured in env vars

set -e

LOG_DIR="$HOME/.openclaw/workspace/logs"
mkdir -p "$LOG_DIR"
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)

# Detect provider from env vars (check in order)
if [ -n "${ANTHROPIC_API_KEY:-}" ]; then
  PROVIDER="Anthropic"
  HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
    -H "x-api-key: ${ANTHROPIC_API_KEY}" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d "{\"model\":\"claude-haiku-20240307\",\"max_tokens\":1,\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}" \
    https://api.anthropic.com/v1/messages 2>/dev/null)

elif [ -n "${OPENAI_API_KEY:-}" ]; then
  PROVIDER="OpenAI"
  HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
    -H "Authorization: Bearer ${OPENAI_API_KEY}" \
    -H "content-type: application/json" \
    -d "{\"model\":\"gpt-4o-mini\",\"max_tokens\":1,\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}" \
    https://api.openai.com/v1/chat/completions 2>/dev/null)

elif [ -n "${GOOGLE_API_KEY:-}" ]; then
  PROVIDER="Google"
  HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
    "https://generativelanguage.googleapis.com/v1beta/models?key=${GOOGLE_API_KEY}" 2>/dev/null)

else
  echo "$TIMESTAMP SKIP no API key env var found" >> "$LOG_DIR/billing-incidents.log"
  exit 0
fi

# Act on the HTTP status code
case "$HTTP_STATUS" in
  200)
    echo "$TIMESTAMP OK $PROVIDER" >> "$LOG_DIR/billing-incidents.log"
    ;;
  402)
    echo "$TIMESTAMP BILLING_ERROR $PROVIDER HTTP_402" >> "$LOG_DIR/billing-incidents.log"
    echo "BILLING ERROR — run the 4-step response protocol above"
    exit 1
    ;;
  401)
    echo "$TIMESTAMP AUTH_ERROR $PROVIDER HTTP_401" >> "$LOG_DIR/billing-incidents.log"
    echo "AUTH ERROR — invalid API key, notify admin"
    exit 1
    ;;
  429)
    echo "$TIMESTAMP RATE_LIMITED $PROVIDER HTTP_429" >> "$LOG_DIR/billing-incidents.log"
    echo "RATE LIMITED — wait 60 seconds and retry. Not a billing issue."
    exit 2
    ;;
  *)
    echo "$TIMESTAMP UNKNOWN $PROVIDER HTTP_$HTTP_STATUS" >> "$LOG_DIR/billing-incidents.log"
    echo "UNKNOWN ERROR HTTP $HTTP_STATUS"
    exit 1
    ;;
esac

HTTP status meanings:

  • 200 → OK
  • 402 → Billing error → run 4-step protocol
  • 401 → Invalid key → notify admin
  • 429 → Rate limit (temporary) → wait and retry, do NOT trigger billing protocol

Fallback Config File

Create config/billing-fallback.json in your workspace:

{
  "primary_provider": "your-primary-provider",
  "primary_model": "your-primary-model",
  "fallback_provider": "your-fallback-provider",
  "fallback_model": "your-fallback-model",
  "admin_phone": "+1XXXXXXXXXX",
  "alert_channel": "whatsapp"
}

Replace placeholders with real values. Examples:

  • Anthropic → OpenAI: "primary_provider": "anthropic", "primary_model": "claude-haiku-20240307", "fallback_provider": "openai", "fallback_model": "gpt-4o-mini"

Recovery (After Credits Restored)

  1. Owner confirms credits are topped up.
  2. Read the primary model name from config:
   PRIMARY=$(python3 -c "
   import json
   with open('config/billing-fallback.json') as f:
       print(json.load(f)['primary_model'])
   ")
  1. Switch back to primary:
   openclaw config set model "$PRIMARY"
  1. Log the recovery:
   echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) BILLING_RESTORED" \
     >> ~/.openclaw/workspace/logs/billing-incidents.log
  1. Notify owner: "✅ Primary model restored. Normal service resumed."

Edge Cases

ScenarioAction
429 rate limitWait 60s, retry. Do NOT trigger billing protocol.
5xx server errorRetry 2x with 10s delay. If persists → notify owner.
Both primary AND fallback billing errorsEscalate to admin immediately. Agent cannot function.
No API key env var setLog as config issue. Notify admin.
Peer PA reports billing errorLog it. Notify admin if you are the network coordinator.

Cost Tips

  • Cheap: Health checks with curl — no LLM cost at all
  • Expensive: Running health checks too frequently wastes money. Every 2 hours is enough.
  • Batch: Combine billing check with other heartbeat checks in one script run
  • Small model OK: This skill needs no reasoning — any model can send a notification message

Running via Cron (Recommended)

Instead of a plugin, run billing-monitor as a scheduled skill via cron:

{
  "id": "billing-health-check",
  "schedule": { "kind": "cron", "expr": "0 * * * *", "tz": "UTC" },
  "sessionTarget": "isolated",
  "payload": {
    "kind": "agentTurn",
    "message": "Run the billing-monitor skill: check all configured API keys for billing errors. If any provider returns 402, send an alert to the admin phone and update billing-status.json. Reply HEARTBEAT_OK if all clear."
  },
  "delivery": { "mode": "silent" }
}

This runs every hour and alerts automatically — no plugin required.

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

90.08%
按下载量换算1,110

安全审计

VirusTotal

未展示

ClawScan

可疑

Static analysis

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills