Skip to content

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

typeHTTPMeaning
invalid_request_error400, 413, 415, 422The request is invalid: fix it before retrying.
authentication_error401Missing, invalid or revoked credentials.
insufficient_credits402Not enough balance.
permission_error403Authenticated but not allowed.
not_found_error404No such object.
conflict_error409Conflicts with an earlier request.
rate_limit_error429Slow down; see Retry-After.
api_error500Unexpected error on our side.
overloaded_error503Temporarily over capacity; see Retry-After.

Error codes

codeHTTPMeaningWhat to do
missing_api_key401No Authorization header.Send Authorization: Bearer <key>.
invalid_api_key401The key is not valid.Check you copied the whole key.
revoked_api_key401The key was revoked.Create a new key in the console.
expired_token401The temporary token expired.Mint a new token and reconnect.
insufficient_credits402Your balance is used up.Add credit in the console or enable auto-recharge.
insufficient_scope403The key lacks the scope for this endpoint.Use a key with the right scope.
org_suspended403Your organisation is suspended.Contact support.
not_found404The object does not exist (or is not yours).Check the ID.
idempotency_conflict409Idempotency-Key reused with a different request.Use a new key per distinct request.
invalid_parameter400A parameter is missing or invalid (see param).Fix the named parameter.
unsupported_language400language is not ar or ar-XX for an Arab country.Use ar.
unknown_model400The model does not exist.Use shihab-asr-v1, or leave model out.
text_too_long400Text to speech: more than 2,000 characters.Split the text into several requests.
unknown_voice400Text to speech: the voice does not exist.Use ps-female or ps-male.
unsupported_dialect400Text to speech: the dialect is not available yet.Use dialect ps (Palestinian).
invalid_url400The URL is not a public HTTPS address.Use a public HTTPS URL.
url_fetch_failed400We could not download the URL.Check it is reachable and not expired.
audio_too_short400Less than 0.2 seconds of audio.Send a longer clip.
file_too_large413Upload larger than 100 MB.Pass a URL instead.
audio_too_long413Longer than 30 minutes on /v1/listen (4 hours async).Use /v1/transcriptions.
unsupported_audio415The file could not be decoded as audio.Send a supported format.
rate_limited429Too many requests per minute.Wait for Retry-After seconds.
concurrency_limit429Too many requests or streams at once.Queue work on your side.
internal_error500Something failed on our side.Retry; contact support with the request_id if it persists.
capacity_exceeded503All transcription capacity is busy.Retry after Retry-After.
engine_unavailable503Transcription 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-After seconds, 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 support

Need help? Email [email protected] or message us on WhatsApp.