fix(auth): rotate keys after DeepSeek insufficient balance

This commit is contained in:
sususu
2026-08-10 10:13:29 +08:00
parent ecc9aa72b3
commit 45ffd115fd
3 changed files with 106 additions and 0 deletions

View File

@@ -80,6 +80,12 @@ func IsRequestFault(status int, err error) bool {
status = statusErr.StatusCode()
}
}
// HTTP 402 is a credential payment or balance failure. Some upstreams,
// including DeepSeek, label it with the generic invalid_request_error code.
// The status is authoritative so the credential can cool down and rotate.
if status == http.StatusPaymentRequired {
return false
}
if hasRequestFaultBody(err) {
return true
}