Skip to main content

Documentation Index

Fetch the complete documentation index at: https://sunbirdai.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

To ensure fair usage and stability, the Sunbird AI API implements rate limiting.

Limits

While specific limits may vary based on your account tier, general guidelines are:
  • Authentication: High limits, but avoid excessive login requests. Reuse tokens.
  • Inference (Translation, STT, TTS): Moderate limits. Avoid bursting hundreds of requests per second.
  • Large Files: Limited concurrency for large file processing.

Handling Rate Limits (429)

If you exceed the rate limit, you will receive a 429 Too Many Requests response.

Best Practices

  1. Reuse Tokens: Do not generate a new access token for every request. Generate one and use it until it expires (7 days).
  2. Batch Processing: If you have many items to process, send them sequentially or with controlled concurrency, rather than all at once.
  3. Exponential Backoff: When you receive a 429 or 503 error, wait for a short period (e.g., 1 second), then retry. If it fails again, wait longer (2 seconds, 4 seconds, etc.).
import time
import requests

def make_request_with_retry(url, payload, headers, max_retries=3):
    for i in range(max_retries):
        response = requests.post(url, json=payload, headers=headers)
        
        if response.status_code == 429 or response.status_code == 503:
            wait_time = 2 ** i  # Exponential backoff: 1, 2, 4 seconds
            time.sleep(wait_time)
            continue
            
        return response
    
    return None