diff --git a/src/proxy/azure.ts b/src/proxy/azure.ts index a4f9ea2..6571e43 100644 --- a/src/proxy/azure.ts +++ b/src/proxy/azure.ts @@ -43,8 +43,8 @@ const azureOpenaiResponseHandler: ProxyResHandlerWithBody = async ( const azureOpenAIProxy = createQueuedProxyMiddleware({ target: ({ signedRequest }) => { if (!signedRequest) throw new Error("Must sign request before proxying"); - const { hostname, path } = signedRequest; - return `https://${hostname}${path}`; + const { hostname, protocol } = signedRequest; + return `${protocol}//${hostname}`; }, mutations: [addAzureKey, finalizeSignedRequest], blockingResponseHandler: azureOpenaiResponseHandler, diff --git a/src/shared/key-management/azure/checker.ts b/src/shared/key-management/azure/checker.ts index 423ee40..bd644ba 100644 --- a/src/shared/key-management/azure/checker.ts +++ b/src/shared/key-management/azure/checker.ts @@ -68,6 +68,14 @@ export class AzureOpenAIKeyChecker extends KeyCheckerBase { }); case "429": const headers = error.response.headers; + const retryAfter = Number(headers["retry-after"] || 0); + if (retryAfter > 3600) { + this.log.warn( + { key: key.hash, errorType, error: error.response.data, headers }, + "Key has an excessive rate limit and will be disabled." + ); + return this.updateKey(key.hash, { isDisabled: true }); + } this.log.warn( { key: key.hash, errorType, error: error.response.data, headers }, "Key is rate limited. Rechecking key in 1 minute."