Skip to content

Operations and retries

Inspect generation status, cancel work, and avoid duplicate submissions.

Speech and cloning create operations. Save X-Request-Id from the response: it identifies an accepted operation. Errors before acceptance may have a tracing ID without an operation.

Inspect an operation

curl --fail --show-error "https://api.sawtakarabi.ai/v1/operations/$OPERATION_ID" \
  -H "Authorization: Bearer $SAWTAK_API_KEY"

Only the owning account can inspect or cancel an operation. Restricted keys require tts for speech or voices for clones.

FieldMeaning
idOperation ID.
statepending or terminal.
outcomenull while pending; otherwise completed, stream_failed, cancelled, failed, not_accepted, or interrupted.
charged_microsCharge in millionths of a US dollar; final once terminal.
completion_bytesIncluded for completed speech: delivered PCM bytes, excluding the WAV header.

Records normally remain for 24 hours from creation with a client-supplied idempotency key, or one hour after settlement without one. A 404 can mean an expired, unknown, or inaccessible operation; it does not establish whether a charge occurred.

Cancel an operation

curl --fail --show-error -X POST \
  "https://api.sawtakarabi.ai/v1/operations/$OPERATION_ID/cancel" \
  -H "Authorization: Bearer $SAWTAK_API_KEY"

Returns {"ok":true} when cancellation is requested. Check status until it becomes terminal, with a delay between checks. Cancellation after audio delivery is still chargeable; see Streaming audio.

Prevent duplicate submissions

Send an Idempotency-Key header of 1–128 UTF-8 bytes with each speech or cloning request. Reuse it when retrying that same request. Keep it separate from the server's operation ID.

  • Retrying an existing pending, completed, or charged operation with the same inputs returns 409 duplicate_request with its operation_id, state, and outcome. Audio is not replayed.
  • For those operations, changed speech settings or changed clone metadata or audio return 409 idempotency_conflict. Retry the original request unchanged; use a new key for a new request. Clone matching ignores multipart boundaries, field order and uploaded filenames.
  • An unsuccessful, uncharged operation releases its key for reuse. Expired keys can also start new work.

Keys are scoped to your account and operation type. Without a supplied key, each submission is a new request. Use the status endpoint to inspect work; resubmitting can start another paid generation.

Interrupted speech

Preserve received audio as incomplete and check operation status before retrying. Retrying cannot recover missing audio and may incur another charge. See Streaming audio and Generation records.