Estimate runway on prepaid API credits
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 code
This is the calculation Argus runs, minus the database:
type Sample = { at: Date; balance: number };
const DAY = 86_400_000;
/** Burn per day from a balance series. Only drops count, so top-ups don't cancel spend. */
function burnPerDay(samples: Sample[]): number {
const s = [...samples].sort((a, b) => +a.at - +b.at);
if (s.length < 2) return 0;
let spent = 0;
for (let i = 1; i < s.length; i++) {
const drop = s[i - 1].balance - s[i].balance;
if (drop > 0) spent += drop;
}
const days = (+s[s.length - 1].at - +s[0].at) / DAY;
return days > 0 ? spent / days : 0;
}
/** null means no runway concern: no burn, or no known balance. */
function daysToZero(balance: number | null, burn: number): number | null {
if (balance == null || burn <= 0) return null;
return balance <= 0 ? 0 : balance / burn;
}Where burn rates go wrong
- Top-ups. Diff the first and last reading and a $100 top-up looks like $100 of negative spend. Count only decreases.
- Too short a window. A one-hour eval run extrapolated to a day says you have hours left. Seven days smooths it; alert thresholds absorb the rest.
- Spend that settles late. OpenRouter's balance can dip slightly below zero after async settlement, and Bright Data deducts usage daily, so its balance moves in steps.
- Credits that aren't dollars. Firecrawl, Hunter and Apollo burn credits. Days to zero works in any unit; dollar totals need a price per credit.
Which number applies to which provider
| Billing shape | Example | What to watch |
|---|---|---|
| Prepaid USD | OpenRouter, DeepSeek, Bright Data | Days to zero |
| Prepaid credits | MillionVerifier, WhoisXML, LeadMagic | Days to zero, in credits |
| Monthly allowance | Firecrawl, Tavily, Hunter, Prospeo | Allowance used vs days to reset |
| Monthly USD budget | Apify | Budget used vs days to cycle end |
| Prepaid, no balance API | OpenAI, Anthropic, Perplexity | Projected month-end vs your cap |
For allowances, zero isn't the end: the allowance resets. Compare days to zero with days to reset. If the allowance lasts past the reset you're fine; if not, you'll hit the provider's overage or hard stop first.
Alert on it
Seven days of runway is a reminder; three is urgent. Argus raises credits_low at seven days and credits_critical at three, and you can set a days-to-zero email alert at any threshold. See low-balance alerts for what each console offers natively.
Questions
- How do I calculate how many days of API credits I have left?
- Divide the current balance by your average daily burn. Measure burn from balance drops over the last 7 days, counting only decreases so top-ups don't hide spend.
- Can I estimate runway for OpenAI or Anthropic credits?
- Not from their APIs alone: neither exposes the prepaid balance. You have the daily spend series, so you can project month-end spend against your monthly cap, or record the balance yourself after each top-up.
Related
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.
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.