Embedding a large collection means thousands of API calls, and every provider limits how many requests and tokens you can send per minute. OpenAI rate limits use RPM (requests per minute), RPD, TPM (tokens per minute) and TPD, and a request can hit either limit first. When a limit is hit, the API returns a 429 error, often with a Retry-After header telling you how many seconds to wait. Plan the ingest around the limits instead of discovering them mid-run.
What you need
- Your usage tier and its RPM and TPM limits
- The total tokens to embed, counted before you start
- A batching script that can pause and retry
Step 1: Count the total tokens before you start
Count the tokens in the whole ingest and divide by the TPM limit to get a minimum ingest time. If the total is far above one minute of tokens, the ingest will take a while, and that is normal.
Step 2: Batch inputs and pace the calls
Send inputs in batches and pace the requests so you stay under both the RPM and TPM limits. Track the remaining-requests and remaining-tokens headers in the responses to see how close you are.
Step 3: Back off on 429 and retry with jitter
When a 429 arrives, wait at least the Retry-After value, then retry with exponential backoff and a small random delay. Do not retry immediately, and do not retry quota or billing errors, which no wait will fix.
Worked example: synthetic ingest pacing for 4 batches
The table below is a synthetic example. It shows the expected result of pacing an ingest; no API was called.
| Batch | Tokens | Result |
|---|---|---|
| Batch 1 | 100,000 | Accepted |
| Batch 2 | 100,000 | Accepted |
| Batch 3 | 100,000 | 429, waited, retried |
| Batch 4 | 100,000 | Accepted |
Expected result (UNTESTED). 3 batches are accepted at once and the rate-limited batch succeeds after waiting for Retry-After. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Rate limits are set at the organization and project level, not per user, and they vary by model.
- A slow_down error can occur even within the RPM and TPM limits when traffic rises too quickly.
- Vector store ingestion can have its own limits, separate from the embedding limits.
- Each official SDK retries eligible 429 responses automatically, so check your SDK retry settings before adding your own.
