DeepSeek returned a rate limit error:
Error: Rate limit exceeded. Please wait before retrying.
Here is how to fix it.
Fix 1: Check your tier
DeepSeek has different limits by tier:
# Check rate limit headers
curl -I https://api.deepseek.com/v1/chat/completions \
-H "Authorization: Bearer $DEEPSEEK_API_KEY"
Limits by tier:
- Free: 10 requests/minute
- Pay-as-you-go: 60 requests/minute
- Enterprise: Custom
Fix 2: Implement retry with backoff
import time
import random
def call_with_retry(prompt, max_retries=5):
for attempt in range(max_retries):
try:
return client.chat.completions.create(
model="deepseek-v4-pro",
messages=[{"role": "user", "content": prompt}]
)
except openai.RateLimitError:
wait = min(60, (2 ** attempt) + random.uniform(0, 1))
print(f"Rate limited, waiting {wait:.1f}s...")
time.sleep(wait)
raise Exception("Max retries exceeded")
Fix 3: Use batch processing
Combine multiple requests:
# Instead of 10 separate requests
results = []
for item in items:
response = call(item)
results.append(response)
# Use batch API (50% cheaper, higher limits)
batch_items = [{"custom_id": str(i), "body": item} for i, item in enumerate(items)]
Fix 4: Switch to Flash model
DeepSeek V4 Flash has higher rate limits:
# Pro: Lower limits
model = "deepseek-v4-pro"
# Flash: Higher limits, faster
model = "deepseek-v4-flash"
Fix 5: Use multiple API keys
Rotate keys for higher throughput:
api_keys = ["key1", "key2", "key3"]
current = 0
def get_key():
global current
key = api_keys[current]
current = (current + 1) % len(api_keys)
return key
Fix 6: Cache responses
Reduce API calls with caching:
import hashlib
import json
cache = {}
def cached_request(prompt):
key = hashlib.md5(prompt.encode()).hexdigest()
if key in cache:
return cache[key]
response = call_api(prompt)
cache[key] = response
return response
Still not working?
- Upgrade tier β More requests per minute
- Use OpenRouter β Different rate limits
- Wait for reset β Limits reset every minute
- Contact support β Request limit increase
FAQ
What are DeepSeekβs rate limits?
Free tier: 10 requests/minute. Pay-as-you-go: 60 requests/minute. Enterprise: Custom. Limits vary by tier and model. Check your usage in the DeepSeek dashboard.
How do I increase my rate limit?
Upgrade to a paid tier for higher limits. You can also use multiple API keys, implement caching, or switch to a faster model like DeepSeek V4 Flash.
Does DeepSeek have daily limits?
Free tier has daily limits. Pay-as-you-go does not have daily limits, only per-minute limits. Enterprise plans have custom limits.
Related: DeepSeek V4 Complete Guide Β· DeepSeek API Timeout Fix Β· AI API Pricing Compared 2026 Β· OpenRouter Complete Guide