Credential status
status | Cause | Recovery |
|---|---|---|
ready | usable | none |
cooling | 429: held until the provider's reset, else 60 s doubling per repeat up to 15 min | automatic when the hold ends, or the next success |
quota | 402, or any refusal whose body says the credit or plan is spent (CreditsError, insufficient_quota, "insufficient balance", Alibaba's 400 Arrearage) | held until the quota reader's reset, else 24 h; a passing check clears it |
invalid_key | 401 or 403 on a key, whose body does not say the credit is spent | replace the key |
needs_login | 401 or 403 on a sign-in after one refresh, or a refused refresh token | sign in again |
A credential's status, cooldown_until_ms and last_error ({at, code, message}) are its whole state. A model the key may not use is blocked on that key alone (blocked_models), not as a status.
The body decides before the status code. OpenCode Zen answers a zero balance with 401 CreditsError; read as a refused key, the page would say "Replace the key" when the fix is a top-up. The phrasings live in one list, errors.py BILLING_MARKERS, taken from the adapters' bodies and the peers' billing tables (hermes-agent _BILLING_PATTERNS, openclaw failover-matches).
What touches the credential
| Response | Credential |
|---|---|
| 429 | Retry-After of 5 s or less: once more on it. Otherwise cooling; the next one is tried |
| 402, spent quota | quota; the next one is tried |
| 401, 403 | invalid_key or needs_login; the next one is tried |
| Model not allowed | That model blocked on it for 24 h |
| 5xx, network | Untouched; sent again on the same key |
| 400, 404, 422 | Untouched |
A switch adds one muted line to the conversation. When nothing is usable, the error lists every credential's state in plain words ("rate limited", "out of quota", "key refused", "sign in again").
Why a hold, and only for these
A limited or spent key must not be sent again on the next request, or every turn pays one refused round trip before switching. A 5xx or a 404 says nothing about the key, so it is never held.
Code
| Where | What |
|---|---|
auth/selection.py classify | A failure as rate limit, quota, refusal, model, server or network; a billing body is quota before 401 or 403 is read |
auth/selection.py mark, succeeded, clear | Set a status and its hold; a success or a passing check returns it to ready |
listing/credentials.py status_from_probe | A check writes ready only on proof of use (OpenRouter GET /key remaining, or a ping 200); an auth-only GET /models 200 does not clear quota |
auth/carry_over.py | The one-time move of the old statuses: needs_reauth and revoked become invalid_key or needs_login (a 24 h quota hold when their error is a billing body), billing_blocked a 24 h quota hold from when it was set; repair applies this once to lists already carried |
detail/credentials-section.tsx | Shows each credential's status as a badge with a dot |
Peers
| Project | Model |
|---|---|
| OpenClaw | cooldownUntil (429, 30 s to 1 m to 5 m), disabledUntil (402 or permanent auth, backoff), blockedUntil (subscription quota reset). 5xx leaves health alone. |
| opencode | No pool. 429 and 5xx retried twice with backoff; the rest are structured errors. |
| Claude Code | Single account; each failure is a chat message with an action. |