Function: classifyKeyFailure()
classifyKeyFailure(
status,body):KeyFailureKind|null
Defined in: packages/agentos/src/core/providers/quotaErrors.ts:112
The kind of key failure an HTTP answer is, or null when the answer is not the key's fault (a bad request, a missing model, a server error, a 403 for a disallowed model or region).
- 401:
auth. 403:authonly for an envelope typeauthentication_error(Anthropic), a codeinvalid_api_key(OpenAI), or a message starting "Invalid authorization token" (Requesty's answer to a bad key, read 17 Oct 2026). Apermission_errororinsufficient_permissionsis a denial of a resource the key may not use (a model, a feature, a region), not a revoked key, and leaves the key in rotation. - 402:
billing. 429:billingwhen the envelope's type or code isinsufficient_quota(OpenAI bills that way) or Anthropic'sdetails.error_codeisenforced_spend_limit_reached(the tier's monthly spend cap, no Retry-After, until the next month), elsequota. 456:quota. - 400:
billingfor Anthropic's credit-balance envelope (typeinvalid_request_error, a message starting "Your credit balance is too low") and for a spend limit the operator set on the organization or a workspace (the same type, a message starting "You have reached your specified API usage limits" or "... specified workspace API usage limits");authfor Google's invalid-key envelope (adetailsentry with reasonAPI_KEY_INVALID, or the message "API key not valid", which the Gemini API answers with HTTP 400, read 17 Oct 2026); every other 400 is null. - A body that is not JSON classifies by status alone.
Parameters
status
number
body
string
Returns
KeyFailureKind | null