{"record":{"id":"b32cd30ce1e3078c","repo":"n8n-io/n8n","slug":"openai-rate-limit-reached","errorCode":null,"errorMessage":"OpenAI: Rate limit reached","messagePattern":"OpenAI: Rate limit reached","errorType":"exception","errorClass":"OperationalError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/helpers/error-handling.ts","lineNumber":50,"sourceCode":"\t\terror.message.includes('not a chat model')\n\t);\n}\n\nexport const openAiFailedAttemptHandler = (error: unknown) => {\n\tif (isNonChatModelError(error)) {\n\t\tthrow new OperationalError(\n\t\t\t'This model requires the Responses API. Enable \"Use Responses API\" in the OpenAI Chat Model node options to use this model.',\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\n\tif (error instanceof RateLimitError) {\n\t\t// If the error is a rate limit error, we want to handle it differently\n\t\t// because OpenAI has multiple different rate limit errors\n\t\tconst errorCode = error?.code;\n\t\tconst errorMessage =\n\t\t\tgetCustomErrorMessage(errorCode ?? 'rate_limit_exceeded') ?? errorMap.rate_limit_exceeded;\n\t\tthrow new OperationalError(errorMessage, { cause: error });\n\t}\n};\n","sourceCodeStart":32,"sourceCodeEnd":53,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/helpers/error-handling.ts#L32-L53","documentation":"When the OpenAI SDK throws a RateLimitError, the openAiFailedAttemptHandler intercepts it and rethrows as an OperationalError with a mapped message. The error code from the OpenAI response is looked up in errorMap (insufficient_quota, rate_limit_exceeded). If no specific code matches, the generic 'OpenAI: Rate limit reached' message is used. This is an operational, transient error — retryable.","triggerScenarios":"The OpenAI account has exceeded its rate limits (requests-per-minute, tokens-per-minute) or has run out of quota (insufficient_quota code). The error comes from the openai SDK's RateLimitError class during any API call (chat, embeddings, images, etc.).","commonSituations":"Running parallel/bulk workflows against OpenAI; hitting the TPM limit on high-token payloads; account is on a free/tier-1 plan with low RPM; monthly quota exhausted.","solutions":["Reduce request concurrency and add delays between calls to stay under RPM/TPM limits","Upgrade your OpenAI API usage tier to increase rate limits","If insufficient_quota, add billing credits or upgrade the plan at platform.openai.com/settings/billing","Implement exponential backoff retry at the workflow level using a Loop node with a Wait"],"exampleFix":"// before — firing 50 concurrent OpenAI requests\n// after  — batch to 5 concurrent with 1s delay between batches","handlingStrategy":"retry","validationCode":"// Estimate token/request budget before calling OpenAI\nconst estimatedRPM = items.length; // requests per minute\nconst rpmLimit = 500; // your tier's RPM limit\nif (estimatedRPM > rpmLimit * 0.8) {\n  // throttle or batch\n  items = batchItems(items, Math.floor(rpmLimit * 0.8));\n}","typeGuard":"import { RateLimitError } from 'openai';\n\nfunction isOpenAiRateLimitError(error: unknown): error is RateLimitError {\n  return error instanceof RateLimitError;\n}","tryCatchPattern":"// In a custom node or code node wrapping OpenAI calls\ntry {\n  await openAiCall();\n} catch (error) {\n  if (error instanceof RateLimitError) {\n    const retryAfter = error.headers?.['retry-after'];\n    await sleep(parseInt(retryAfter ?? '60') * 1000);\n    return openAiCall(); // retry once\n  }\n  throw error;\n}","preventionTips":["Batch requests to stay at 80% of your RPM/TPM limit","Add Wait nodes between loop iterations for bulk operations","Monitor OpenAI usage dashboard for quota approaching limits","Upgrade your OpenAI tier if consistently hitting rate limits"],"tags":["openai","rate-limit","quota","transient","operational"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}