402 — Insufficient credits

When HiWay refuses a request because the balance can't cover it.

HiWay returns a 402 in two distinct cases. Read the error.message field to know which one you hit.

Case 1 — Empty balance

json
{
  "error": {
    "message": "Insufficient credits (balance: $0.0000). Buy credits at /billing/checkout",
    "type": "billing_error",
    "balance": 0.0
  }
}

Your balance is at zero. Go to Dashboard → Billing, pick an amount, and complete the Stripe checkout. You can also enable Auto-recharge so this never happens again.

Case 2 — Worst-case cost too high

json
{
  "error": {
    "message": "Insufficient credits for this request (estimated max $0.0040, balance $0.0010). Top up at /billing",
    "type": "billing_error",
    "estimated_cost": 0.004046,
    "balance": 0.001
  }
}

Your balance is positive but smaller than the worst-case cost HiWay computes for this specific request. Two ways to fix it:

  • Top up more credits. Even $5 is enough to unblock most requests.
  • Lower `max_tokens`. The worst-case cost is dominated by max_tokens × output_price/M. Drop it from 4096 to 500 and the estimate shrinks 8×.

Why we're strict

Once HiWay forwards your request to the provider, the provider charges us, regardless of how many tokens come back. So we have to be sure your balance covers the worst case before we forward — otherwise we eat the cost. The strict pre-flight check is what lets us guarantee you can never overdraft.