Dealing with API Errors
If the model provider returns an error from their API, by default LangChain will retry up to 6 times on an exponential backoff. This enables error recovery without any additional effort from you. If you want to change this behavior, you can pass a maxRetries
option when you instantiate the model. For example:
import { OpenAI } from "langchain/llms/openai";
const model = new OpenAI({ maxRetries: 10 });