Guides
Errors
The error envelope, every error type and code, and how to handle them.
Error shape
Every error, on every endpoint, has the same JSON body and a matching HTTP status. param names the offending input when there is one; request_id equals the X-Request-Id header.
415 Unsupported Media Type
{
"error": {
"type": "invalid_request_error",
"code": "unsupported_audio",
"message": "The file could not be decoded as audio. Send WAV, MP3, M4A, OGG, WebM or FLAC.",
"param": "file",
"request_id": "req_01JA8Z6Q3K7M2V9X4T5R8N1B6C"
}
}Error types
| type | HTTP | Meaning |
|---|---|---|
| invalid_request_error | 400, 413, 415, 422 | The request is invalid: fix it before retrying. |
| authentication_error | 401 | Missing, invalid or revoked credentials. |
| insufficient_credits | 402 | Not enough balance. |
| permission_error | 403 | Authenticated but not allowed. |
| not_found_error | 404 | No such object. |
| conflict_error | 409 | Conflicts with an earlier request. |
| rate_limit_error | 429 | Slow down; see Retry-After. |
| api_error | 500 | Unexpected error on our side. |
| overloaded_error | 503 | Temporarily over capacity; see Retry-After. |
Error codes
| code | HTTP | Meaning | What to do |
|---|---|---|---|
| missing_api_key | 401 | No Authorization header. | Send Authorization: Bearer <key>. |
| invalid_api_key | 401 | The key is not valid. | Check you copied the whole key. |
| revoked_api_key | 401 | The key was revoked. | Create a new key in the console. |
| expired_token | 401 | The temporary token expired. | Mint a new token and reconnect. |
| insufficient_credits | 402 | Your balance is used up. | Add credit in the console or enable auto-recharge. |
| insufficient_scope | 403 | The key lacks the scope for this endpoint. | Use a key with the right scope. |
| org_suspended | 403 | Your organisation is suspended. | Contact support. |
| not_found | 404 | The object does not exist (or is not yours). | Check the ID. |
| idempotency_conflict | 409 | Idempotency-Key reused with a different request. | Use a new key per distinct request. |
| invalid_parameter | 400 | A parameter is missing or invalid (see param). | Fix the named parameter. |
| unsupported_language | 400 | language is not ar or ar-XX for an Arab country. | Use ar. |
| unknown_model | 400 | The model does not exist. | Use shihab-asr-v1, or leave model out. |
| text_too_long | 400 | Text to speech: more than 2,000 characters. | Split the text into several requests. |
| unknown_voice | 400 | Text to speech: the voice does not exist. | Use ps-female or ps-male. |
| unsupported_dialect | 400 | Text to speech: the dialect is not available yet. | Use dialect ps (Palestinian). |
| invalid_url | 400 | The URL is not a public HTTPS address. | Use a public HTTPS URL. |
| url_fetch_failed | 400 | We could not download the URL. | Check it is reachable and not expired. |
| audio_too_short | 400 | Less than 0.2 seconds of audio. | Send a longer clip. |
| file_too_large | 413 | Upload larger than 100 MB. | Pass a URL instead. |
| audio_too_long | 413 | Longer than 30 minutes on /v1/listen (4 hours async). | Use /v1/transcriptions. |
| unsupported_audio | 415 | The file could not be decoded as audio. | Send a supported format. |
| rate_limited | 429 | Too many requests per minute. | Wait for Retry-After seconds. |
| concurrency_limit | 429 | Too many requests or streams at once. | Queue work on your side. |
| internal_error | 500 | Something failed on our side. | Retry; contact support with the request_id if it persists. |
| capacity_exceeded | 503 | All transcription capacity is busy. | Retry after Retry-After. |
| engine_unavailable | 503 | Transcription is temporarily unavailable. | Retry with backoff. |
Streams report errors as {"type":"Error","code":"...","message":"..."} followed by a close code; see close codes.
Handling errors
- Do not retry 4xx errors (except 429) without changing the request.
- Retry 429 and 503 after the
Retry-Afterseconds, and 500 with exponential backoff. - Log request_id with every failure; it lets us find the request instantly.
The SDKs raise typed errors and retry 429, 503 and connection failures for you:
from shihab_asr import (
APIError,
BadRequestError,
InsufficientCreditsError,
RateLimitError,
ShihabASR,
)
client = ShihabASR() # retries 429, 503 and connection errors automatically
try:
result = client.listen("call.m4a")
except InsufficientCreditsError:
print("Out of credit: top up in the console")
except BadRequestError as e:
print("Check the audio or parameters:", e.code, e.param)
except RateLimitError as e:
print("Still rate limited after retries; wait", e.retry_after, "s")
except APIError as e:
print(e.status_code, e.code, e.message, e.request_id) # quote request_id to supportNeed help? Email [email protected] or message us on WhatsApp.