n8n-io/n8n · error · OperationalError
OpenAI: Rate limit reached
Error message
OpenAI: Rate limit reached
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/helpers/error-handling.ts:50
error.message.includes('not a chat model')
);
}
export const openAiFailedAttemptHandler = (error: unknown) => {
if (isNonChatModelError(error)) {
throw new OperationalError(
'This model requires the Responses API. Enable "Use Responses API" in the OpenAI Chat Model node options to use this model.',
{ cause: error },
);
}
if (error instanceof RateLimitError) {
// If the error is a rate limit error, we want to handle it differently
// because OpenAI has multiple different rate limit errors
const errorCode = error?.code;
const errorMessage =
getCustomErrorMessage(errorCode ?? 'rate_limit_exceeded') ?? errorMap.rate_limit_exceeded;
throw new OperationalError(errorMessage, { cause: error });
}
};
View on GitHub (pinned to 5ac6606e81)
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
Example fix
// before — firing 50 concurrent OpenAI requests // after — batch to 5 concurrent with 1s delay between batches
Defensive patterns
Strategy: retry
Validate before calling
// Estimate token/request budget before calling OpenAI
const estimatedRPM = items.length; // requests per minute
const rpmLimit = 500; // your tier's RPM limit
if (estimatedRPM > rpmLimit * 0.8) {
// throttle or batch
items = batchItems(items, Math.floor(rpmLimit * 0.8));
} Type guard
import { RateLimitError } from 'openai';
function isOpenAiRateLimitError(error: unknown): error is RateLimitError {
return error instanceof RateLimitError;
} Try / catch
// In a custom node or code node wrapping OpenAI calls
try {
await openAiCall();
} catch (error) {
if (error instanceof RateLimitError) {
const retryAfter = error.headers?.['retry-after'];
await sleep(parseInt(retryAfter ?? '60') * 1000);
return openAiCall(); // retry once
}
throw error;
} Prevention
- 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
When it happens
Trigger: 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.).
Common situations: 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.
Related errors
- Rate limit exceeded. Please wait a moment and try again.
- admittance_rejected
- Failed to retrieve API Key
- Database connection timed out
- Timed out after ${timeoutMs}ms waiting for database connecti
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/b32cd30ce1e3078c.
Report an issue: GitHub.