handles 'this organization is disabled' error from anthropic

This commit is contained in:
nai-degen
2024-03-06 00:42:10 -06:00
parent ddf34685df
commit 8f46bd4397
2 changed files with 22 additions and 0 deletions
+11
View File
@@ -450,6 +450,17 @@ async function handleAnthropicBadRequestError(
return;
}
const isDisabled = error?.message?.match(/organization has been disabled/i);
if (isDisabled) {
req.log.warn(
{ key: req.key?.hash, message: error?.message },
"Anthropic key has been disabled."
);
keyPool.disable(req.key!, "revoked");
errorPayload.proxy_note = `Assigned key has been disabled. ${error?.message}`;
return;
}
errorPayload.proxy_note = `Unrecognized error from the API. (${error?.message})`;
}