handles keys which have been banned (but not revoked) by openai

This commit is contained in:
nai-degen 2023-07-19 10:28:38 -05:00
parent c749e2d57d
commit d7a4829d13
2 changed files with 11 additions and 0 deletions

View File

@ -221,6 +221,13 @@ export class OpenAIKeyChecker {
"Key is out of quota. Disabling key."
);
this.updateKey(key.hash, { isDisabled: true });
}
else if (status === 429 && data.error.type === "access_terminated") {
this.log.warn(
{ key: key.hash, isTrial: key.isTrial, error: data },
"Key has been terminated due to policy violations. Disabling key."
);
this.updateKey(key.hash, { isDisabled: true });
} else {
this.log.error(
{ key: key.hash, status, error: data },

View File

@ -377,6 +377,10 @@ function handleOpenAIRateLimitError(
// Billing quota exceeded (key is dead, disable it)
keyPool.disable(req.key!);
errorPayload.proxy_note = `Assigned key's quota has been exceeded. ${tryAgainMessage}`;
} else if (type === "access_terminated") {
// Account banned (key is dead, disable it)
keyPool.disable(req.key!);
errorPayload.proxy_note = `Assigned key has been banned by OpenAI for policy violations. ${tryAgainMessage}`;
} else if (type === "billing_not_active") {
// Billing is not active (key is dead, disable it)
keyPool.disable(req.key!);