Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.supertoneapi.com/llms.txt

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

The Supertone API uses standard HTTP status codes. Errors return a JSON body describing the problem, and the SDKs surface them as typed exceptions you can catch and handle.

Status code reference

StatusMeaningMost common cause
200 OKSuccess
400 Bad RequestMalformed requestMissing required field, invalid enum value, text over 300 chars (raw API only), voice_settings out of range.
401 UnauthorizedAuth failureMissing or invalid x-sup-api-key.
402 Payment RequiredNot enough creditsCredit balance is zero or insufficient for the request.
403 ForbiddenNo permissionTrying to call a custom voice owned by a different account, or using a key without permission.
404 Not FoundResource missingWrong voice_id, mistyped endpoint path.
408 Request TimeoutServer couldn’t process in timeTransient — retry.
413 Payload Too LargeUpload too bigVoice-clone audio over 3 MB.
415 Unsupported Media TypeBad upload formatVoice-clone audio not WAV/MP3.
429 Too Many RequestsRate limit hitSee Rate limits.
500 Internal Server ErrorServer-side issueUsually transient — retry with backoff.

SDK error classes

Both SDKs map each status code to a typed error class. Catching the specific class is cleaner than parsing strings.
from supertone import errors

try:
    response = client.text_to_speech.create_speech(...)
except errors.BadRequestErrorResponse as e:
    # 400 — fix the request
    log.error("Bad request: %s", e.message)
except errors.UnauthorizedErrorResponse:
    # 401 — re-check the API key
    rotate_key_and_retry()
except errors.PaymentRequiredErrorResponse:
    # 402 — alert the user / billing system
    notify_low_credits()
except errors.ForbiddenErrorResponse:
    # 403 — wrong voice for this account
    fallback_to_preset_voice()
except errors.TooManyRequestsErrorResponse:
    # 429 — back off and retry
    backoff_and_retry()
except errors.InternalServerErrorResponse:
    # 500 — retry transient failure
    retry_with_backoff()
except errors.SupertoneError as e:
    # Any other API-level error
    log.exception("Supertone API error: %s", e.message)
Every SDK error exposes:
PropertyDescription
messageServer-provided error message.
status_code / statusCodeThe HTTP status code.
headersResponse headers.
bodyRaw response body string.
raw_response / rawResponseUnderlying HTTP response object.

What to do with each error

4xx — your side

CodeRecommended response
400Don’t retry — log the request body and fix the schema mismatch.
401Check key value, key activation in the console, and that the x-sup-api-key header isn’t being stripped by a proxy.
402Surface “insufficient credits” to the user, link to billing, and stop the workflow. Retrying without adding credits will fail again.
403Confirm the voice belongs to this account. Custom voices are account-scoped.
404Confirm the voice_id exists by calling GET /v1/voices or GET /v1/custom-voices.
413Reduce upload size — re-encode to mono, lower bitrate, or trim to under 3 MB.
415Re-encode the upload as WAV or MP3.
429See Retries and backoff.

5xx — our side

CodeRecommended response
408Retry — usually transient.
500Retry with exponential backoff. If failures persist (>5 minutes), contact support.

Common pitfalls

  • Content-Type: application/json missing on POST requests results in 400.
  • API key with leading/trailing whitespace (often from copy-paste) results in 401.
  • Calling a custom voice from a different account results in 403, even if you “know” the ID.
  • Sending text over 300 characters to the raw API results in 400. Use an SDK to auto-chunk longer text.

Retries and backoff

The right retry policy for 429 and 5xx.

Rate limits

Limits by account tier.