Retries and idempotency

Retry a request safely: the same Idempotency-Key makes the job once.

Networks fail. If you send a job request and the answer gets lost, you can't know whether the job was made. Send an Idempotency-Key header (any unique string up to 255 characters, a UUID is ideal) with every job request:

  • The first request with a key makes the job and charges for it once.
  • The same key with the same body returns that job again (HTTP 200, header Idempotent-Replayed: true), without a second job or charge.
  • The same key with a different body is refused with idempotency_conflict.

Keys are scoped to the API key that sent them. Retry with backoff (1 s, 2 s, 4 s…) on network errors, 429 and 5xx; don't retry other 4xx without changing the request.

Retries and idempotency — Luce API