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