treats 403 from anthropic as key dead
This commit is contained in:
@@ -314,7 +314,11 @@ const handleUpstreamErrors: ProxyResHandlerWithBody = async (
|
||||
keyPool.disable(req.key!, "revoked");
|
||||
errorPayload.proxy_note = `API key is invalid or revoked. ${tryAgainMessage}`;
|
||||
} else if (statusCode === 403) {
|
||||
// Amazon is the only service that returns 403.
|
||||
if (service === "anthropic") {
|
||||
keyPool.disable(req.key!, "revoked");
|
||||
errorPayload.proxy_note = `API key is invalid or revoked. ${tryAgainMessage}`;
|
||||
return;
|
||||
}
|
||||
switch (errorType) {
|
||||
case "UnrecognizedClientException":
|
||||
// Key is invalid.
|
||||
|
||||
@@ -48,13 +48,14 @@ export class AnthropicKeyChecker extends KeyCheckerBase<AnthropicKey> {
|
||||
protected handleAxiosError(key: AnthropicKey, error: AxiosError) {
|
||||
if (error.response && AnthropicKeyChecker.errorIsAnthropicAPIError(error)) {
|
||||
const { status, data } = error.response;
|
||||
if (status === 401) {
|
||||
if (status === 401 || status === 403) {
|
||||
this.log.warn(
|
||||
{ key: key.hash, error: data },
|
||||
"Key is invalid or revoked. Disabling key."
|
||||
);
|
||||
this.updateKey(key.hash, { isDisabled: true, isRevoked: true });
|
||||
} else if (status === 429) {
|
||||
}
|
||||
else if (status === 429) {
|
||||
switch (data.error.type) {
|
||||
case "rate_limit_error":
|
||||
this.log.warn(
|
||||
|
||||
Reference in New Issue
Block a user