Does @langchain/openai AzureChatOpenAI respect the retry-after header when being rate-limited? #6683
-
Checked other resources
Commit to Help
Example CodeThis is not the actual code i'm trying to run, but just an example to attempt to hit the rate limit. (RPM/TPM) import { AzureChatOpenAI } from '@langchain/openai';
const generationChatModel = new AzureChatOpenAI({
azureOpenAIApiKey: process.env.GENERATION_AZURE_OPENAI_API_KEY,
azureOpenAIApiInstanceName: process.env.GENERATION_AZURE_OPENAI_API_INSTANCE_NAME,
azureOpenAIApiDeploymentName: process.env.GENERATION_AZURE_OPENAI_API_DEPLOYMENT_NAME,
model: 'gpt-4o',
maxTokens: 128_000,
});
const systemPrompt = "...";
const text = "...";
// Example to bump into rate-limit azure openAI ChatCompletions_Create
for (let i = 0; i < 150; i++) {
const result = await generationChatModel.invoke([
['system', systemPrompt],
['human', text],
]);
console.log(result.content);
} DescriptionI have a code-flow that often bumps in to Azure OpenAI rate limits. This itself is not a problem i'm trying to fix. I am however curious if Langchain.JS uses the Azure provided 'retry-after' header to set it's retry-logic's timeout? System Info[email protected] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey @JonathanVelkeneers! I'm here to assist you with any bugs, questions, or contributions you may have. Let's work together to resolve your concerns. The |
Beta Was this translation helpful? Give feedback.
The
AzureChatOpenAI
class in the@langchain/openai
package does not specifically check for theretry-after
header in the response from the Azure OpenAI API [1][2].To continue talking to Dosu, mention @dosu.