Blog · DeepSeek

DeepSeek API Rate Limits & Errors: 429, Timeouts, Retry

Every DeepSeek developer eventually hits a 429, a timeout, or a retry storm. This guide explains the exact error codes, what they mean, and how to handle them — including how a gateway can absorb most of the pain.

Last updated: 2026-10-08. Error codes below reflect the DeepSeek API as of 2026-09-10; gateway behavior described is AI24X's current implementation.

1. The DeepSeek API error codes you will actually see

DeepSeek's API returns OpenAI-style error bodies: a JSON object with error.message, error.type, and error.code. Here are the ones that matter in production:

HTTPError typeWhat it meansRetry?
401invalid_request_errorBad or missing API keyNo — fix the key
402insufficient_quotaAccount balance exhaustedNo — top up
403permission_errorModel not allowed for this keyNo — check access rules
404invalid_request_errorUnknown model or endpointNo — check the model ID
408request_timeoutServer took too longYes — with backoff
429rate_limit_exceededToo many requests / tokens per minuteYes — respect Retry-After
500api_errorServer-side failureYes — with backoff
503api_errorService unavailable / overloadedYes — with backoff

Two of these deserve special attention:

  • 429 rate_limit_exceeded — the most common production error. DeepSeek limits both requests per minute (RPM) and tokens per minute (TPM). Hitting either triggers 429. The response includes a Retry-After header (in seconds) — respect it.
  • 402 insufficient_quota — different from 429. This means your balance hit zero. Retrying will not help; you need to top up.

2. Timeouts and connection errors

Beyond error codes, you will encounter transport-level failures:

  • Connection timeout — the server did not accept the connection within your client's timeout window (often 10–30s). Common during peak hours.
  • Read timeout — the connection opened but the response did not arrive in time. LLM generation for long outputs can legitimately take 30–120s+, so set generous read timeouts.
  • Stream interruption — with stream=true, the SSE connection can drop mid-stream. The request may have partially completed server-side.

Golden rule: never retry a request that may have completed. If you got a partial stream or a timeout on a non-idempotent call, verify state before re-sending — otherwise you can double-bill yourself on tokens. Idempotency keys or a "check before retry" pattern are worth the engineering time.

3. Retry with exponential backoff — the correct pattern

For retryable errors (408, 429, 500, 503), use exponential backoff with jitter. A solid default:

import time
import random
import requests

def call_with_retry(url, headers, payload, max_retries=5):
    for attempt in range(max_retries):
        resp = requests.post(url, headers=headers, json=payload, timeout=120)
        if resp.status_code not in (408, 429, 500, 503):
            return resp
        # Respect Retry-After when present
        retry_after = resp.headers.get("Retry-After")
        if retry_after is not None and resp.status_code == 429:
            delay = float(retry_after)
        else:
            delay = (2 ** attempt) + random.uniform(0, 1)
        time.sleep(min(delay, 60))
    return resp  # give up after 5 attempts

Rules that prevent retry storms:

  • Respect Retry-After on 429 — never hammer a rate-limited endpoint.
  • Cap the delay at 60s for the official platform.
  • Never retry 401/402/403/404 — they will not succeed until you change something.
  • Add jitter — synchronized retries from many clients create thundering herds.
  • Bound total retries (3–6 attempts) so a degraded upstream does not hang your job forever.

4. How a gateway changes the picture

When you call DeepSeek through an aggregator like AI24X, most of this complexity moves server-side:

  • Multi-channel routing — if the DeepSeek direct channel is 429ing or timing out, the gateway can route to another upstream that serves the same model family, instead of failing your request.
  • Automatic model switching — degraded channels are detected and bypassed until they recover.
  • Rate-limit absorption — the gateway pools and distributes capacity across upstream accounts, so a single client's burst is less likely to trip a per-account limit.
  • One retry policy — you implement backoff once, against one endpoint, instead of maintaining per-provider retry logic for DeepSeek, Qwen, GLM, Kimi, and the rest.
  • Consistent error surface — gateway errors follow the OpenAI-style body, so your client code handles one shape.

That is the practical value of a gateway for reliability: your requests succeed more often because the failure handling happens upstream, and the errors you do see are normalized.

5. A note on peak-hour load

DeepSeek's official peak hours are 01:00–04:00 and 06:00–10:00 UTC, Monday–Friday — which overlap exactly with US/EU business hours. During those windows, the official platform is under the heaviest load, and 429s and timeouts are more common. Two mitigations:

  • Shift batch work off-peak — DeepSeek charges half price off-peak and the platform is less loaded. Batch jobs belong in UTC evenings/weekends.
  • Route interactive traffic through a gateway — the gateway spreads load across channels, so interactive calls are less likely to hit a single account's rate ceiling.

6. Copy-paste setup (with the gateway)

Base URL (OpenAI-compatible)

https://api.ai24x.com/v1

Quick test with curl

curl -X POST "https://api.ai24x.com/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ***" \
  -d '{"model":"flash","messages":[{"role":"user","content":"Hello!"}],"max_tokens":100}'

Python with OpenAI SDK (retries built in)

from openai import OpenAI

client = OpenAI(
    base_url="https://api.ai24x.com/v1",
    api_key="***",
    max_retries=3,  # SDK-level backoff on 429/5xx
    timeout=120.0
)

response = client.chat.completions.create(
    model="flash",
    messages=[{"role": "user", "content": "Explain retry with backoff in one sentence."}]
)
print(response.choices[0].message.content)

Existing OpenAI SDKs and tools (Open WebUI, LobeChat, Cursor, Dify, LiteLLM, n8n) connect the same way: change base URL + key, keep the rest of your code.

7. FAQ

What does DeepSeek 429 mean?

429 rate_limit_exceeded means you exceeded the requests-per-minute or tokens-per-minute limit for your account tier. Wait for the Retry-After period (or use exponential backoff) before retrying. Through AI24X, the gateway absorbs per-account limits by routing across channels.

Is 402 the same as 429?

No. 402 insufficient_quota means your balance is empty — top up, do not retry. 429 means rate limiting — back off and retry.

Should I retry a timed-out request?

Only if you can verify the request did not complete. A timeout on a long generation may still have produced tokens server-side. Prefer idempotent patterns or check-before-retry to avoid double-billing.

Why do I get timeouts during peak hours?

DeepSeek's peak windows (01:00–04:00 and 06:00–10:00 UTC, Mon–Fri) overlap with US/EU business hours, so the platform is under heaviest load. Shift batch work off-peak, or route interactive traffic through a gateway with multi-channel switching.

Does AI24X have rate limits?

AI24X applies fair-use limits per key tier, but because it routes across multiple upstream channels, a single client's burst is far less likely to trip a per-account ceiling. See the console docs for current tier limits.

Is AI24X the official DeepSeek API?

No. AI24X is an independent AI gateway (not affiliated with DeepSeek) that routes to DeepSeek and other models through one OpenAI-compatible key.

8. Getting started

  1. Register at https://www.ai24x.com and create an API key in the console.
  2. Top up at console → billing (PayPal or card).
  3. Use the base_url + key from the setup section in any OpenAI-compatible tool — done.

Developer docs: https://open.ai24x.com · Console: https://www.ai24x.com/console.html · Pricing: https://www.ai24x.com/pricing.html

Educational/informational article. This page is not affiliated with DeepSeek and does not constitute investment advice of any kind. All prices are as captured on the dates noted and may change; always check official pricing pages.

One API. Every AI. Pay Less.

Start Building Free Get API Key View pricing

Related: DeepSeek API pricing · How to use DeepSeek API · DeepSeek vs Qwen vs GLM · AI model routing & automatic switching · DeepSeek model page