Skip to content
Guides & reference

Errors, limits & security

Predictable JSON error envelopes, explicit WebSocket close codes, clear rate/concurrency ceilings, and strict zero-retention privacy guarantees.

Zero-billing on errorsRetry-After headersX-Data-Retention: zero

Error response shape

Every non-2xx HTTP response returns a JSON object with a stable machine-readable code and an actionable message:

JSON
{
  "error": {
    "code": "insufficient_balance",
    "message": "Your balance does not cover this request.",
    "type": "billing_error"
  }
}

HTTP status codes

StatusCodeRetryable?What to do
400invalid_requestNoFix the field named in error.message.
401unauthorizedNoCheck your bearer key. Revoked keys stop working within 30 seconds.
402insufficient_balanceAfter top-upYour balance does not cover this request. Add credit.
413payload_too_largeNoSTT upload exceeds 25 MiB. Compress to 16 kHz mono Opus/MP3/M4A or split.
429rate_limitedYesWait the seconds in Retry-After (rate or concurrency ceiling), then retry.
503unavailableYesService temporarily at capacity or unavailable. Wait for Retry-After and retry with backoff.

Failed requests are never charged. Retrying after any 4xx or 5xx error, or after an upstream TTS stream drop, costs $0.

Recommended retry logic

import time, httpx

def request_with_retry(client: httpx.Client, method: str, url: str, **kwargs) -> httpx.Response:
    for attempt in range(4):
        resp = client.request(method, url, **kwargs)
        if resp.status_code not in (429, 503):
            return resp
        retry_after = float(resp.headers.get("Retry-After", 2 ** attempt))
        time.sleep(min(retry_after, 30.0))
    return resp

WebSocket close codes (WS /v1/audio/stream)

CodeMeaning & recovery
4400Invalid query parameter, unknown model, or streaming disabled for that model. Fix the URL before reconnecting.
4401Missing, invalid, or expired credentials, or credentials sent in the query string (?api_key= / ?token=). Authenticate via header, subprotocol, or first-frame JSON.
4402Insufficient balance at connect (< 60 s credit) or balance exhausted mid-stream. Top up before reconnecting.
4429Per-key rate limit or 4-stream concurrency limit reached. Back off and close idle sockets.
4503Live streaming is temporarily unavailable. Retry with jittered backoff.

Common 400 validation messages

Text to speech (POST /v1/audio/speech)

MessageFix
Streaming is not available for this voice yet. Use `spero-f1`, or leave it out.Stream in spero-f1, or set stream: false.
`stream` must be true or false.Send a JSON boolean.
With `stream`, `response_format` must be `pcm` or `wav`.Ask for pcm or wav, or omit response_format (defaults to pcm).
With `stream`, `input` must be at most 600 characters.Shorten the text or request a file.
With `stream`, `input` must be one paragraph.Send a single paragraph per stream.
`speed` cannot be used with `stream`.Omit speed when streaming.
`sample_rate` cannot be used with `stream`.Omit sample_rate when streaming.
`speed` must be a number from 0.9 to 1.1.Send a number in [0.9, 1.1].
`sample_rate` must be 8000, 16000 or 24000.Send one of those three rates.
With `opus`, leave `sample_rate` out: Opus has its own rates.Omit sample_rate or use another format.
With `ulaw`, `sample_rate` must be 8000 or left out.Omit sample_rate or pass 8000.
Unknown response_format. Use one of: mp3, wav, flac, opus, pcm, ulaw.Pick one of the six TTS formats.

Speech to text (POST /v1/audio/transcriptions)

MessageFix
Unknown response_format. Use one of: json, verbose_json, text.Use json, verbose_json, or text.
With `stream`, `response_format` must be `json` or left out.Omit response_format or pass json when using SSE.
`language` must be an ISO language code such as `en`.Pass a supported code like en, es, tr, ja, or auto.
`prompt` must be at most 1000 characters.Keep glossary hints within 1,000 characters.
`transcription_mode` must be one of: verbatim, clean, verbatim_latin.Use verbatim, clean, or verbatim_latin.
`temperature` must be a number between 0 and 1.Pass a finite float in [0.0, 1.0].

Limits & quotas

LimitDefault value
TTS file input2,000 characters · max 12 paragraphs · max 100 chars/word · 64 KiB JSON body
TTS stream input1 paragraph · max 600 characters (spero-f1)
STT file upload25 MiB per file · up to 60 minutes audio
STT glossary promptUp to 1,000 characters
STT live WebSocket45 minutes max session length · 5 s auth window if using first-frame JSON auth
Concurrency (per key & account)4 TTS · 8 batch STT · 4 live STT WebSocket streams simultaneously
Request rate120 requests/minute per key
API keys10 active keys per account
Capacity protectionExcess requests under heavy load return 503 with a Retry-After header

Zero data retention & security

  • Audit logs contain metadata only: model ID, request ID, character count or audio seconds, cost, and status codes. Validation errors never echo user text.
  • Key hygiene: sp_live_ keys are shown once at creation and stored hashed. Keep them strictly server-side; revoke compromised keys from API keys (takes effect within 30 s).
  • Browser clients: never bundle sp_live_ keys into frontend JavaScript. Mint a short-lived session token server-side and authenticate WebSockets via Sec-WebSocket-Protocol: spero-auth, bearer.<jwt>.