# Error: 429 You exceeded your current quota, please check your plan and billing details. (Node.js)

Thrown by the openai Node SDK as RateLimitError (its stack prints Error) when the API answers 429. The SDK already retried twice by default (maxRetries 2) before throwing. The message and error.code come from OpenAI's response: a rate limit ("Rate limit reached for requests" or tokens) or a billing problem (the long-standing "You exceeded your current quota" message, credit_balance_exhausted in the current error reference).

```
Error: 429 You exceeded your current quota, please check your plan and billing details.
    at APIError.generate (node_modules/openai/core/error.mjs:59:20)
    at OpenAI.makeStatusError (node_modules/openai/client.mjs:446:32)
    at OpenAI.makeRequest (node_modules/openai/client.mjs:1014:30)
  status: 429, code: 'insufficient_quota'
```

## Quick fix

Look at error.code and the message before touching retries. Quota or credit errors mean the account is out of money or past its spend limit: add credits or raise the limit, and stop retrying. Rate limit errors mean you are sending too fast: respect the Retry-After header, back off with jitter, and lower concurrency.

1. Log error.status, error.code and the message for every 429.
2. Quota, billing or credit codes: add credits or raise the project spend limit in the OpenAI dashboard. Retrying will not help.
3. Rate limit codes: wait as long as Retry-After says, then retry with exponential backoff and jitter, and cap retries.
4. Remember the SDK already retried twice; set maxRetries deliberately rather than stacking your own loop on top.
5. Reduce bursts: queue requests, lower parallelism, batch where you can.

```ts
import OpenAI, { RateLimitError } from 'openai';

const openai = new OpenAI({ maxRetries: 3 }); // the SDK backs off between retries

try {
  return await openai.chat.completions.create({ model, messages });
} catch (err) {
  if (err instanceof RateLimitError && /quota|credit|billing/i.test(`${err.code} ${err.message}`)) {
    // Out of credits or over the spend limit: tell someone, don't retry
    throw new Error('OpenAI account is out of credits', { cause: err });
  }
  throw err;
}
```

## Why it happens

### No credits or spend limit reached

The organization or project has no prepaid credits left or hit its monthly limit. Every request fails until billing changes.

### Too many requests at once

A burst of parallel calls (a backfill, a fan-out, a retry storm) passes the per-minute request or token limit.

### Retries that make it worse

Your own retry loop on top of the SDK's two retries multiplies traffic during a rate limit.

### A key from another project

The key belongs to a project with lower limits or no credits.

## Other fixes

- Alert on quota errors the first time they happen: they stop every AI feature at once and nothing recovers without a billing change.
- Keep rate-limit retries out of user-facing request paths when you can; queue the work instead.

## Same error, other wording

- `RateLimitError: 429 Rate limit reached for requests`
- `openai.RateLimitError: Error code: 429 - You exceeded your current quota, please check your plan and billing details.`
- `Error code: 429 - credit_balance_exhausted`

## Sources

- [OpenAI docs: error codes (429 rate limit vs credit balance, retry guidance)](https://developers.openai.com/api/docs/guides/error-codes)
- [openai-node README: retries (default 2) and errors](https://github.com/openai/openai-node#retries)

---

To see this error the next time it happens in production, with the stack trace and the steps before it: Runheed records it and serves it to your coding agent over MCP. Setup instructions an agent can follow: https://runheed.com/SETUP.txt

Human-readable version: https://runheed.com/errors/openai-429-rate-limit-or-quota
