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 { ChatOpenAI } from "langchain/chat_models/openai";
const model = new ChatOpenAI({ maxRetries: 10 });