Task commitment and retry
Why an accepted generation task cannot be canceled, and how failed or expired tasks are retried safely.
Once createTask is accepted, the generation task is committed and cannot be canceled. This rule applies while it is queued as well as while it is running: upstream providers do not offer a reliable cancellation contract, so SpicyAPI never exposes a local action that could report cancellation while generation and provider billing continue.
Accepted tasks are irreversible
Review the model, inputs and estimated charge before submitting. Closing the browser, leaving the page or deleting an API key does not stop an accepted task.
Retry a terminal task
POST /api/v1/jobs/retrycurl -X POST https://api.spicyapi.ai/api/v1/jobs/retry \
-H "Authorization: Bearer $SPICY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: retry-order-8814-1" \
-d '{"taskId":"job_01k3m8x9q2z4v7n5p6r8s0t1w3"}'Only failed and expired tasks should be retried. Historical canceled records remain readable and may also be retried for backward compatibility, but new tasks cannot enter that state through a user action. Success creates a new queued task:
{
"code": 200,
"msg": "success",
"data": {
"taskId": "job_01k3mnewtask",
"sourceTaskId": "job_01k3m8x9q2z4v7n5p6r8s0t1w3",
"state": "queued",
"estimatedCost": "0.08"
},
"request_id": "req_01k3mretry"
}- The source task remains terminal and unchanged.
- The new task's
sourceTaskIdpoints to the source, preserving retry lineage. - Current schema, price, permission, balance, and routing checks run again. The same upstream is not guaranteed.
Idempotency-Keyis scoped to the source task and retry action. Same key and semantics return the same new task; different semantics return409.
A network error is not a failed task
If a createTask connection breaks before the response arrives, replay createTask with its original Idempotency-Key. Use retry only when an existing task has a confirmed terminal state.
State and retry matrix
| Current state | What you can do |
|---|---|
queued / running | Wait for the terminal result; the task cannot be canceled |
succeeded | Read or download the result; create a new task for another generation |
failed / expired | Retry to create a separately billed task |
historical canceled | Read the record or retry it; no new user cancellation is available |

