Not live-tested: this guide was checked against documentation on November 19, 2026. No APIrove or model API requests were made. Client versions, enabled models and limits need separate verification.
Decide what the 429 means first
A status alone is not a recovery instruction. Inspect the structured error locally, any Retry-After header, and your console usage. A depleted balance or exhausted allowance needs action; waiting in a loop cannot restore access. No APIrove request or concurrency limit is promised here.
| Observed condition | Next action |
|---|---|
| Confirmed temporary request or token rate limit | Reduce concurrency and request size; queue work and pace submissions. |
| Balance or allowance exhausted | Pause the queue; check the dashboard before resuming. |
| Concurrency ceiling | Let active requests finish and cap workers; do not rotate keys. |
| Unknown or non-JSON response | Stop automatic retries and inspect a redacted diagnostic. |
Python and Node.js backoff
These wrappers accept a one-request function; they do not connect anywhere by themselves. The two temporary codes below are from the official OpenAI documentation, not a guarantee of APIrove error codes. Confirm the returned code before adapting the allowlist. There are at most four attempts; a server delay over the local wait budget is handed back for scheduling, never shortened.
Use only for a non-streaming request rejected before output, when replay is safe. Set a finite timeout in send(), disable SDK retries there (for example max_retries=0 in Python or maxRetries: 0 in Node.js), and manage one total deadline for the whole operation.
import random
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
def retry_after_seconds(value):
if value is None:
return 0.0
try:
return max(0.0, float(value))
except ValueError:
try:
stamp = parsedate_to_datetime(value)
return max(0.0, (stamp - datetime.now(timezone.utc)).total_seconds())
except (TypeError, ValueError, OverflowError):
return 0.0
def with_backoff(send, sleep=time.sleep):
# send() makes ONE non-streaming request and returns an HTTP response.
# Disable retries inside send(). Exceptions propagate without replay.
for attempt in range(4):
response = send()
try:
error = response.json().get("error", {})
code = error.get("code") if isinstance(error, dict) else None
except (ValueError, AttributeError):
code = None
# Only documented temporary codes; unknown codes require inspection.
if response.status_code != 429 or code not in {
"rate_limit_exceeded", "slow_down"
} or attempt == 3:
return response
delay = max(2 ** attempt, retry_after_seconds(
response.headers.get("Retry-After"))) + random.uniform(0, 0.5)
if not 0 <= delay <= 60:
return response # hand back for a later scheduled attempt
response.close() # release the connection before waiting
sleep(delay)
# Inject your one-request function: response = with_backoff(send)
# No request runs when this example is loaded.function retryAfterSeconds(value) {
if (!value) return 0;
const seconds = Number(value);
if (Number.isFinite(seconds)) return Math.max(0, seconds);
const stamp = Date.parse(value);
return Number.isNaN(stamp) ? 0 : Math.max(0, (stamp - Date.now()) / 1000);
}
async function withBackoff(send, sleep = ms => new Promise(r => setTimeout(r, ms))) {
// send() makes ONE non-streaming fetch with a timeout and no inner retries.
// Network/timeout exceptions propagate; do not replay them automatically.
for (let attempt = 0; attempt < 4; attempt++) {
const response = await send();
if (response.status !== 429) return response;
let code;
try { code = (await response.clone().json()).error?.code; } catch (_) {}
if (!["rate_limit_exceeded", "slow_down"].includes(code) || attempt === 3) {
return response;
}
const seconds = Math.max(2 ** attempt,
retryAfterSeconds(response.headers.get("Retry-After"))) + Math.random() * 0.5;
if (!(seconds >= 0 && seconds <= 60)) return response;
if (response.body) await response.body.cancel();
await sleep(seconds * 1000);
}
}
// Inject your one-request function: const response = await withBackoff(send);
// No request runs when this example is loaded.Check usage before resuming
- Inspect balance and access and usage without sharing personal details.
- Keep the same model and endpoint while lowering concurrent work. Check the selected key can use the model.
- Resume gradually; SDK retries and application retries multiply when both are enabled.
For APIrove configuration, the Base URL is:
https://apirove.com/v1Authentication or missing-model problems: 401 / 403 / 404. For uncertain completion or interrupted output, see timeouts and streaming.
Sources: OpenAI error guide and rate-limit recovery. They describe OpenAI behavior; inspect APIrove's actual response before applying a recovery rule.
Optional one-request diagnostic
After correcting access or pacing, set APIROVE_API_KEY securely and replace the enabled model ID. This would make a real Chat Completions request, with no automatic retry. It has not been run for this guide.
# APIROVE_API_KEY must already be set securely in your shell.
curl --silent --show-error --connect-timeout 10 --max-time 45 \
https://apirove.com/v1/chat/completions \
-H "Authorization: Bearer ${APIROVE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_ENABLED_MODEL_ID","messages":[{"role":"user","content":"Reply OK"}],"stream":false}'Related guides
Request troubleshooting overview · Endpoint and request formats · Model directory · Key security
FAQ
Does every 429 need a retry?
No. Confirm a temporary rate limit first. Balance, access and allowance errors need a separate correction.
Should I change keys to bypass a limit?
No. Reduce concurrent work and check the limits and permissions in your console.
Is a Retry-After value a maximum wait?
No. Treat it as a minimum delay. If it exceeds your wait budget, schedule later instead of retrying early.
New to APIrove? Register, check the available top-up options, then create a key. Existing users can follow the checks above.
Get started with APIrove