Pre-recorded Audio — Error Handling

Retry & Backoff Strategies

The SDK retries server errors automatically. For rate limits, implement exponential backoff.


SDK automatic retries

The SDK retries 5xx errors and connection failures automatically. Configure via max_retries:

python
client = AsyncShunyaClient(max_retries=5, timeout=120.0)

Exponential backoff for rate limits

python
import asyncio
from shunyalabs.exceptions import RateLimitError

async def transcribe_with_backoff(client, file, config, retries=3):
    for attempt in range(retries):
        try:
            return await client.asr.transcribe(file, config=config)
        except RateLimitError:
            wait = 2 ** attempt
            print(f"Rate limited. Retrying in {wait}s...")
            await asyncio.sleep(wait)
    raise RateLimitError("Max retries exceeded")
Note: The SDK does NOT automatically retry RateLimitError (429). You must implement backoff yourself.