Fix OpenAI API 429 "Rate limit reached ... tokens per min"
When the OpenAI API returns 429 with tokens per min (TPM) Limit, Used and Requested, learn to read the numbers, then cut max_tokens, wait, or batch.
Rate limit reached for gpt-4-turbo-preview in organization org-... on tokens per min (TPM): Limit 30000, Used 4811, Requested 28049. Please try again in 5.72s. Visit https://platform.openai.com/account/rate-limits to learn more.You hit the tokens-per-minute (TPM) rate limit. This is not the same as You exceeded your current quota, where credits or a spend limit ran out. That one does not clear by waiting; this one does. The difference is laid out in OpenAI API 429 "You exceeded your current quota". The message above comes from a real case on the OpenAI forum (model name as posted, organization ID shortened). That case came from the Assistants API: a message was appended to an existing thread, then a run started. For Chat-style calls follow the steps as written; for Assistants, also check the thread history in step 2.
[1] Read the numbers. The message gives the limit, what is already used, and what this request needs.
| Field | Value | Meaning |
|---|---|---|
| Limit | 30000 | Tokens per minute for this organization and model |
| Used | 4811 | Already used in the current minute window |
| Requested | 28049 | What this request needs |
4811 + 28049 = 32860, which is over 30000, so the request was refused. Here a single request asked for almost the whole limit. When Requested alone exceeds Limit, waiting will not help; shrink the request.
[2] Find out why Requested is big. The official rate limits guide says the amount counted is calculated from the larger of max_tokens and the estimated token count (its wording: "maximum of max_tokens and the estimated number of tokens"). A short reply with a large max_tokens still reserves that much. The docs advise setting max_tokens close to the expected response size. A large input also inflates Requested. In an Assistants call like the one above, where messages pile up in one thread, the accumulated history is fed back as input and each run can grow. Then max_tokens alone will not shrink it; look at starting a fresh thread or limiting how much history a run reads. The setting names and method were not confirmed in the official docs here.
[3] Lower max_tokens. If replies run around 500 tokens but max_tokens is 4096, set it to what you need. Once Requested drops, the request fits again.
[4] Split large inputs. A long document sent whole can reach the limit on input tokens alone. Split it and send the parts in order. A prompt longer than the model's maximum is not a rate limit; see the maximum context length error.
[5] Wait the time in the message, then resend. The case above said Please try again in 5.72s. If a Retry-After header is present, the docs treat it as a minimum wait and suggest adding a small random delay. Without it, retry with exponential backoff and jitter, and cap the number of retries. Failed requests count toward the per-minute limit, so resending nonstop keeps you blocked.
[6] Read the remaining budget from headers. x-ratelimit-remaining-tokens and x-ratelimit-reset-tokens show the tokens left and the time until reset; x-ratelimit-remaining-requests shows the request count left. Limits apply on whichever of requests (RPM) or tokens (TPM) is hit first, so check both.
[7] Move work that does not need an instant answer to the Batch API. The docs say to use it when you do not need immediate responses, and that batch usage does not affect synchronous request limits.
[8] Check whether the limit itself can go up. Limits are per organization and vary by model, and rise with your usage tier. This article could not confirm the per-tier numbers, so read them on your account's rate limits page.
Check it with the HTTP status codes tool ↗ — calculated in your browser.