diff --git a/src/proxy/middleware/response/index.ts b/src/proxy/middleware/response/index.ts index 8f21220..0b5823c 100644 --- a/src/proxy/middleware/response/index.ts +++ b/src/proxy/middleware/response/index.ts @@ -455,7 +455,9 @@ async function handleAnthropicAwsBadRequestError( // {"type":"error","error":{"type":"invalid_request_error","message":"Your credit balance is too low to access the Claude API. Please go to Plans & Billing to upgrade or purchase credits."}} const isOverQuota = error?.message?.match(/usage blocked until/i) || - error?.message?.match(/credit balance is too low/i); + error?.message?.match(/credit balance is too low/i) || + error?.message?.match(/You will regain access on/i) || + error?.message?.match(/reached your specified API usage limits/i); if (isOverQuota) { req.log.warn( { key: req.key?.hash, message: error?.message }, @@ -468,7 +470,8 @@ async function handleAnthropicAwsBadRequestError( const isDisabled = error?.message?.match(/organization has been disabled/i) || - error?.message?.match(/^operation not allowed/i); + error?.message?.match(/^operation not allowed/i) || + error?.message?.match(/credential is only authorized for use with Claude Code/i); if (isDisabled) { req.log.warn( { key: req.key?.hash, message: error?.message }, diff --git a/src/shared/key-management/anthropic/checker.ts b/src/shared/key-management/anthropic/checker.ts index 96e37a3..3d8135d 100644 --- a/src/shared/key-management/anthropic/checker.ts +++ b/src/shared/key-management/anthropic/checker.ts @@ -76,7 +76,8 @@ export class AnthropicKeyChecker extends KeyCheckerBase { data.error?.message?.match(/You will regain access on/i); const isDisabled = data.error?.message?.match( /organization has been disabled/i - ); + ) || + data.error?.message?.match(/credential is only authorized for use with Claude Code/i); if (status === 400 && isOverQuota) { this.log.warn( { key: key.hash, error: data },