Pre-recorded Audio — Error Handling

Handling Common Errors

Wrap API calls in try/except blocks to handle errors gracefully.


Handling pattern

python
from shunyalabs.exceptions import (
    AuthenticationError, RateLimitError,
    TranscriptionError, ServerError, ShunyalabsError
)

try:
    result = await client.asr.transcribe("audio.wav", config=config)
except AuthenticationError:
    print("Invalid API key — check SHUNYALABS_API_KEY")
except RateLimitError:
    print("Rate limit hit — back off and retry")
except TranscriptionError as e:
    print(f"Transcription failed: {e}")
except ServerError:
    print("Server error — safe to retry")
except ShunyalabsError as e:
    print(f"Unexpected SDK error: {e}")