billing-monitor
Monitor for API billing errors and alert the owner and admin immediately.
Skill by netanel-abergel
Chalk Labs
Need help deploying billing-monitor?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/netanel-abergel-billing-monitor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, ml
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/billing-monitor
What's inside
- Skill 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.).
- License
- MIT
- Instructions
- 243 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (1)
- SKILL.md
SKILL.md (first lines)
# Billing Monitor Skill
## 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.
---
## 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
```bash
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:
```bash
#!/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"From netanel-abergel/pa-skills, MIT.
Signals
- Stars
- 6
- Forks
- 1
- Open issues
- 0
- Last commit (this folder)
- Apr 10, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/netanel-abergel/pa-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get billing-monitor running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
billing-monitor skill. Agent Mart. https://agentmart.dev/skills/netanel-abergel-billing-monitor (last updated 2026-10-24)