Set a low-balance alert for OpenAI, Anthropic and OpenRouter
What each console's own alerts do, what they can't see, and how to alert on days of runway left instead of a dollar threshold.
GET /api/v1/credits and alert when total_credits − total_usage gets low. Whatever the provider, alert on days of runway left, not a dollar figure.What each provider gives you
| OpenAI | Anthropic | OpenRouter | |
|---|---|---|---|
| Native alert | Spend alerts and hard spend limits per org or project | Spend limits and notification thresholds per workspace and org | Credit limit per key |
| Balance over API | No | No | Yes, GET /api/v1/credits |
| Spend over API | Daily, GET /v1/organization/costs | Daily, GET /v1/organizations/cost_report | Per call (usage.cost) |
| Error at zero | 429 insufficient_quota | 400 credit balance too low | 402 |
Sources: OpenAI spend limits, Claude Console workspaces, OpenRouter credits. Native limits are worth setting whatever else you do: they're the only thing that actually stops spend.
A dollar threshold is the wrong alert
$20 left is a week on a quiet project and an hour during an eval run. The alert you want is "this runs out before I'll be back": days to zero, which is balance over burn per day. A 7-day warning gives you time to top up; a 3-day one means now. Those are the thresholds Argus uses for credits_low and credits_critical. The math is in estimating runway.
Do it yourself for OpenRouter
The cheapest working version is a cron job with curl and jq:
#!/usr/bin/env bash
# Run hourly from cron. Alerts when OpenRouter credits drop under $10.
set -euo pipefail
remaining=$(curl -sf https://openrouter.ai/api/v1/credits \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
| jq '.data.total_credits - .data.total_usage')
if (( $(echo "$remaining < 10" | bc -l) )); then
curl -sf -X POST "$SLACK_WEBHOOK_URL" \
-d "{\"text\": \"OpenRouter balance is \$$remaining\"}"
fiIt works, and it has the gaps every one-off script has: it fires every hour until you top up, it knows one provider, and it can't tell a slow week from a runaway one.
With Argus
- Low balance: fires under a USD threshold, for any provider with a readable balance.
- Days to zero: fires when runway at the current burn drops under N days.
- Spend spike: fires when week-over-week spend rises by a percentage you set.
- Projected overage: fires when projected month-end spend reaches a USD amount you set.
- Rate-limit headroom, error rate and cost drift, for the failures that aren't about money running out.
- Each rule watches one connection or all of them, fires once by email, and re-arms when the condition clears.
For OpenAI and Anthropic, where there's no balance to read, use spend spike and projected overage. Your coding agent sees the same warnings through get_advisories over MCP.
Questions
- Can I get an alert when my OpenAI credit balance is low?
- Not on the balance itself: OpenAI exposes no balance API, and its console notifications are thresholds on spend. Alert on monthly spend against your cap, or track the balance yourself after each top-up.
- Does Anthropic send low balance emails?
- The Claude Console lets you add notification thresholds on workspace and organization spend limits, and shows the credit balance on the billing page. The balance isn't available from the Admin API.
- How do I alert on OpenRouter credits?
- Poll GET https://openrouter.ai/api/v1/credits; total_credits minus total_usage is your balance in USD. Alert when it crosses a threshold, or better, when days of runway left drops under a week.
Related
Days to zero is balance over burn rate. The hard part is the burn rate: top-ups, daily buckets and credits that aren't dollars.
The balance endpoint, auth header and response field for every major metered API, and the ones that only show a balance in the console.
Connect a provider key, point Claude Code or Cursor at the Argus MCP server, and ask what the last run cost.