HTTP 402 Insufficient Balance / Quota — Wallet & Cap Fix

Returned when wallet balance cannot cover the request pre-hold or a per-key spend limit is reached. Alert billing ops instead of looping retries.

Need resilient routing with automatic multi-upstream failover and full request telemetry on API Store Hub?

HTTP 402 Insufficient Balance / Quota — Wallet & Cap Fix visual architecture diagram — API Store Hub
HTTP 402 Insufficient Balance / Quota — Wallet & Cap Fix · Base URL https://apistorehub.com · Key prefix sk-ash-

Error runbook

HTTP Status402
Error typeinsufficient_quota
Retry policyFix request first

Returned when wallet balance cannot cover the request pre-hold or a per-key spend limit is reached. Alert billing ops instead of looping retries.

Metadata & root causes

  • Available wallet balance is lower than the estimated cost of input tokens plus requested max_tokens.
  • The API key reached its custom daily/monthly quota cap even though the main wallet still has funds.
  • Setting an unnecessarily huge max_tokens (e.g. 64000) for short tasks inflates the pre-hold check.

3 steps to resolve

  1. Immediate diagnosis: Check wallet balance and the individual sk-ash- key cap in the API Store Hub console.
  2. Apply standard fix: Top up instantly via automated QR transfer at /dashboard/nap-vi or raise the key spend limit.
  3. Prevent recurrence in production: Right-size max_tokens (512–4096) and configure low-balance alerts to prevent downtime.

Production retry & recovery snippet

cURL

curl -i https://apistorehub.com/v1/chat/completions \
  -H "Authorization: Bearer sk-ash-your_key" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-flash","max_tokens":128,"messages":[{"role":"user","content":"check quota"}]}'

TypeScript

export async function guardQuotaCall<T>(fn: () => Promise<T>, alertLowBalance: () => Promise<void>): Promise<T> {
  try {
    return await fn();
  } catch (err: any) {
    if (err?.status === 402) {
      await alertLowBalance();
    }
    throw err;
  }
}

Frequently asked questions

Am I billed on API Store Hub when an HTTP 402 (insufficient_quota) error occurs?
No. Atomic pre-hold settlement on API Store Hub automatically releases any reserved amount for failed requests that return no valid completion.
How do I tell whether the error originated from my client or upstream?
4xx codes (except 429) usually point to auth headers, wallet quota, or request payload formatting; 429/502/504/529 indicate load or transient upstream conditions visible on /status.
Can I fall back to another model without changing SDKs?
Yes. Pass the fallback model ID (e.g. across Claude, GPT, DeepSeek, or Gemini) inside your retry catch block using your existing sk-ash- API key.