From 57924a8e35465b30d3a621d6353f3f0857d21008 Mon Sep 17 00:00:00 2001 From: david kim Date: Fri, 25 Jul 2025 00:28:40 -0700 Subject: [PATCH] support anthropic's error code --- packages/proxy/src/proxy.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/proxy/src/proxy.ts b/packages/proxy/src/proxy.ts index 3d32c188..1ebff76b 100644 --- a/packages/proxy/src/proxy.ts +++ b/packages/proxy/src/proxy.ts @@ -899,7 +899,8 @@ export async function proxyV1({ } const RATE_LIMIT_ERROR_CODE = 429; -const OVERLOADED_ERROR_CODE = 503; +// Anthropic uses 529 for overloaded errors, while many providers use 503. +const OVERLOADED_ERROR_CODES = [503, 529]; const RATE_LIMIT_MAX_WAIT_MS = 45 * 1000; // Wait up to 45 seconds while retrying const BACKOFF_EXPONENT = 2; @@ -912,14 +913,14 @@ const TRY_ANOTHER_ENDPOINT_ERROR_CODES = [ // intelligently, eg if all APIs are rate limited, back off and try something else. RATE_LIMIT_ERROR_CODE, - // 503 is overloaded. We may want to track stats about this and potentially handle more + // 503 and 529 is overloaded. We may want to track stats about this and potentially handle more // intelligently, eg if all APIs are overloaded, back off and try something else. - OVERLOADED_ERROR_CODE, + ...OVERLOADED_ERROR_CODES, ]; const RATE_LIMITING_ERROR_CODES = [ RATE_LIMIT_ERROR_CODE, - OVERLOADED_ERROR_CODE, + ...OVERLOADED_ERROR_CODES, ]; const GOOGLE_URL_REGEX =