# 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.

## Spend caps

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](https://app.directinference.com/api-keys) page and the account cap in [Billing](https://app.directinference.com/billing) settings; the current-period spend against each is shown alongside it.

## When a cap is hit

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`.

```json title="402 · spend cap reached"
{
  "error": {
    "message": "api key has reached its monthly spend limit",
    "type": "invalid_request_error",
    "code": "spend_limit_exceeded"
  }
}
```

```json title="402 · balance exhausted"
{
  "error": {
    "message": "insufficient credit balance",
    "type": "invalid_request_error",
    "code": "insufficient_credit"
  }
}
```

:::caution[402 is not 429]
A `402` is a deliberate stop — raise the cap or top up, then retry; it will not clear on its own. A `429` is transient pressure on the serving endpoint and clears with backoff. See [Errors & limits](https://docs.directinference.com/errors/) for the full status-code reference.
:::

## Balance, top-ups & auto-recharge

Your balance is shown in [Billing](https://app.directinference.com/billing) and updates live as requests complete. Set a low-balance threshold to get an in-app banner before you run dry, top up in a tap through Stripe Checkout, and optionally enable auto-recharge so a saved card refills the balance when it dips below your threshold.

:::tip[Pair a cap with a top-up]
A spend cap protects you from a runaway job; auto-recharge protects you from unplanned downtime. Most teams set both — a comfortable account cap and a modest auto-recharge — and never think about balance again.
:::