Перейти к навигации

Can resubmitting a timed-out image start create two tasks?

Resubmitting a timed-out POST /v1/images/tasks request does not create a second task when the retry reuses the original Idempotency-Key, request path, and exact JSON body within 24 hours. The gateway replays the stored 201 response with the Idempotent-Replayed: true header rather than queuing another render.

Safe recovery steps after a timeout

  1. Check local storage for a saved task_id (data.id). When a task_id already exists, query GET /v1/tasks/{task_id} instead of calling POST /v1/images/tasks again.
  2. When no task_id reached the client and the original request included an Idempotency-Key (at most 255 characters), resend the identical path, header, and JSON body within 24 hours.
  3. Persist the Idempotency-Key, request body, and returned task_id together on the order or asset record so later retries stay traceable.
curl -sS -X POST 'https://api.beatapi.io/v1/images/tasks' \
-H "Authorization: Bearer $BEATAPI_API_KEY" \
-H "Idempotency-Key: bg-edit-sku-1042-v1" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2.5-flare-std","prompt":"Replace the background with light gray studio paper.","images":["https://example.com/product.jpg"]}'

Conflict and new-key boundaries

  • In-flight or mismatched requests (409 idempotency_conflict): Reusing a key while the first request is still running, or pairing the key with a changed body or path, returns 409 idempotency_conflict. Wait for the original request to finish before retrying an identical payload.
  • Failed validation or balance checks: BeatAPI stores idempotency records only for 2xx responses. After a 400 or 402 refusal, fix the request or balance and submit again.
  • Distinct tasks: Generate a fresh Idempotency-Key whenever the prompt, reference image, or parameters change for a new asset.

Image reference

Before sending a paid request, inspect the model contracts for free: model:gpt-6-luna, model:gpt-image-2.5-flare-std.

Back to AI Models questions.