Task lifecycle
Create once, observe progress, then save the result.
Create
POST /api/v1/openapi/task creates a task. The plural /api/v1/openapi/tasks is a supported alias. Prefer the authorized catalog's item_key. Historical identifier fields remain accepted in this order: item_key, model_key, model, then model_id.
Omit type to let the task service infer it from the public item projection; a supplied type must match. A nonempty top-level prompt fills parameters.prompt only when that property is absent. An existing value, including an empty one, wins. provider is a rejected legacy field. Use the model-specific schema for the remaining parameters.
metadata.reference_id is server-managed: client values are removed, and the trimmed X-Idempotency-Key supplies it. Capacity controls such as user_capacity_mode, queue_deadline, execution_deadline, service_class and concurrency receipts are also server-managed and rejected when supplied.
Your account, key, model access, and applicable balance checks must pass before the request is accepted. Check the current model catalog and account configuration when creation is rejected.
Observe
GET /api/v1/openapi/task/status/{task_id} and the plural /tasks/status/{task_id} require a valid task UUID and enforce ownership. The response always includes task_id, status, estimated_duration_ms. Empty message, error, timestamps and result can be omitted.
| Status | Client action |
|---|---|
pending | Wait; the task is accepted but not complete. |
running | Keep polling with backoff. |
finalizing | Result delivery is still being finalized. |
completed | Save the returned result. |
failed | Read the public error; stop polling. |
cancelled | Stop polling. |
created_at, completed_at, expires_at are Unix seconds. estimated_duration_ms is milliseconds, and zero is valid. The public result is filtered to output_urls and batch_results. Batch items may appear while the parent is still running; do not infer parent completion from a partial result.
Use output URLs exactly as returned; do not replace their hostnames.
When completed_at is set for a terminal task, expires_at = completed_at + 1800. A lookup after expiry returns 404 with reason STATUS_EXPIRED in the error details. Persist what your application needs promptly.
Batch results
For models exposing batch_size, MuseSpark can repeat the model execution inside one logical task. Keep polling the parent task ID. An individual execution can complete or fail while the parent is still processing.
Save successful batch results when the parent reaches a terminal state. A partial result does not establish completion of all requested executions.
Idempotency and retries
Use the same X-Idempotency-Key for retries of the same business intent. The task service scopes the record by user and stable identity, compares a canonical request fingerprint, and can reuse the accepted task. A different request under that identity is an invalid request (400), not a documented 409 contract.
Reuse is subject to the idempotency record's retention window. Persist both your key and any returned task ID, and query an existing task before submitting again. Do not assume permanent deduplication or exactly-once execution after records expire.
A timed-out creation request may already have been accepted. Reuse the same key and the same request intent when retrying; changing the key can start another paid execution.