Skip to main content

Retryable Errors

These errors can be safely retried:
  • 429 Rate limit exceeded
  • 500 Internal server error
  • 502 Bad gateway
  • 503 Service unavailable

Exponential Backoff

import time
import random

def retry_with_backoff(func, max_retries=3):
    for attempt in range(max_retries):
        try:
            return func()
        except RateLimitError as e:
            if attempt == max_retries - 1:
                raise
            delay = (2 ** attempt) + random.uniform(0, 1)
            time.sleep(delay)

SDK Auto-Retry

The SDK handles retries automatically:
client = Rubric(
    max_retries=3,
    retry_delay=1.0
)