AniwaffleDocsHomeStudio

API reference

Errors

Every error has a stable code and a retryable flag. Handle errors by code and retryable, never by the detail text.

Error format

HTTP errors return a JSON body with a 4xx or 5xx status. Streaming errors arrive as an error event, which ends the request.

json
{
  "event": "error",
  "request_id": "rq_0f8c2d4e-...",
  "code": "invalid_request",
  "retryable": false,
  "detail": "String must contain at least 1 character(s)"
}
FieldTypeDescription
request_idstringThe request's ID. Include it when you contact support.
codestringStable, machine-readable error code.
retryablebooleantrue if the same request can succeed on a new attempt.
detailstringHuman-readable explanation. Its wording can change; don't parse it.

Idempotency and job errors return a shorter body with only code (idempotency errors also include request_id), plus the status and headers listed below.

Error codes

CodeStatusRetryMeaning and action
invalid_request400NoThe JSON, a field, the event order, a tag or a limit is invalid, or the voice is not available to this workspace. Fix the request.
invalid_voice400NoThe voice can't be used with the requested model, or has no usable recording. Choose another voice or omit model.
unsupported_output_format400NoThe model can't produce this format. Choose one listed in GET /v1/models.
unauthorized401NoThe API key or stream token is missing, invalid, expired or revoked.
insufficient_credit402NoThe workspace balance is too low. Buy credits under Billing in Studio, then retry.
capability_disabled403NoText to Speech is not enabled for this workspace.
organization_suspended403NoThe workspace is suspended. Contact us.
idempotency_conflict409NoThe Idempotency-Key was already used with a different body. Use a new key.
idempotency_in_progress409YesThe original request with this key is still running. Retry after Retry-After.
batch_in_progress409YesThe job hasn't finished. Retry after Retry-After.
idempotency_result_unavailable410NoThe original result failed or expired. Send a new request with a new key.
batch_result_unavailable410NoThe job failed or expired. Submit a new job with a new key.
batch_not_found404NoNo job with this ID exists in the workspace.
idempotency_key_required400NoPOST /v1/tts/jobs needs an Idempotency-Key of 1–200 characters.
rate_limited429YesCapacity is temporarily full. Retry with backoff.
batch_queue_full429YesThe workspace has 20 jobs queued or running. Retry after Retry-After.
provider_error5xxIf retryableSpeech generation failed. Retry only if retryable is true; otherwise contact us with the request_id.
provider_unavailable5xxIf retryableThe speech service is temporarily unavailable. Retry with backoff.
organization_account_missing503NoThe workspace's billing account is not set up. Contact us.

Retries

  • Retry only when retryable is true, or the status is 409 or 429 with a Retry-After header.
  • Wait at least Retry-After seconds when present. Otherwise use exponential backoff with jitter, for example 1, 2, 4 and 8 seconds.
  • Send an Idempotency-Key with POST /v1/tts so a retry after a lost response can't generate or charge twice.
  • A streaming retry is a new WebSocket connection with a new request_id.
  • A streaming error can arrive after some audio has played. Decide whether to replay the whole utterance or resume at a sentence boundary, so the listener doesn't hear the same words twice.

WebSocket handshake and close codes

A rejected API key, stream token or browser origin fails the handshake with HTTP 401, before the connection opens. After the connection opens:

Close codeMeaning
1000Normal close after finish.
1008A control message was binary or not valid JSON.
1009A control message was larger than 64 KiB.

Other protocol mistakes, such as a second start or a text event after stop, end the request with an invalid_request error event.

Contact our team

Tell us about your character and what you’d like to build.