Requests and media

Idempotency

Retry a submit safely with an Idempotency-Key.

A network error after a submit leaves you unsure whether the job was created. Send an Idempotency-Key header on every generate request, and retry with the same key: you get the original job back instead of a second, billed one.

Rules

  • The key is 1 to 255 printable ASCII characters. A UUID per request is the simple choice.
  • The same key with the same request returns the original job, with "idempotency_hit": true. You are charged once.
  • The same key with a different request (another model, prompt or setting) answers 409 idempotency_conflict. Make a new key for a new request.
  • The key is stored on the job as idempotency_key, so you can find the job again with List jobs.

What it covers

Idempotency keys apply to the generate operations. Reads (status, result, list) are safe to repeat as they are.

On dev, 42 submits with one key in parallel made one job and one charge.