Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/proxy/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 =
Expand Down
Loading