Skip to content

Spend & limits

Hard caps per key and per account, a live balance, and one-tap top-ups — so a runaway loop can never overspend, and a low balance never surprises you.

You can set a hard spending cap on an individual API key and on the whole account, each as a monthly or daily limit. Both are enforced before a request is dispatched — the key cap is checked first, then the account cap — so a cap is never exceeded, only reached. Set a per-key cap on the API Keys page and the account cap in Billing settings; the current-period spend against each is shown alongside it.

A request blocked by a cap returns HTTP 402 in your surface’s error envelope, with a code that tells you which limit applied. The account-level message reads “account has reached its monthly spend limit”. A zero balance returns 402 with insufficient_credit.

402 · spend cap reached
{
"error": {
"message": "api key has reached its monthly spend limit",
"type": "invalid_request_error",
"code": "spend_limit_exceeded"
}
}
402 · balance exhausted
{
"error": {
"message": "insufficient credit balance",
"type": "invalid_request_error",
"code": "insufficient_credit"
}
}

A 402 raised by a spend cap also carries a Retry-After header — the whole number of seconds until the cap window resets — so a client can schedule its next attempt. Capped keys additionally receive a per-request budget on successful responses; see Rate-limit headers.

Your balance is shown in Billing and updates live as requests complete. Set a low-balance threshold to get an in-app banner before you run dry, and top up in a tap through Stripe Checkout. With a saved card you can enable auto-recharge: pick a threshold and a refill amount, and the balance is topped up off-session whenever it dips below the threshold. A declined charge surfaces the error in Billing and pauses auto-recharge until you fix the card.

Check your balance over REST — GET /v1/credits

Section titled “Check your balance over REST — GET /v1/credits”

Read your live balance programmatically with your llm_live_... key (also on …/di/v1/credits):

GET /v1/credits
curl https://api.directinference.com/v1/credits \
-H "Authorization: Bearer llm_live_..."
200
{ "balance": "9.871234", "total_used": "0.128766" }

balance is your remaining credit and total_used your spend to date, both in USD. For spend and per-request cost over time, see the usage REST API.