MuseSpark
MuseSpark
Guides

Retrieve and save results

Poll an asynchronous MuseSpark task, distinguish terminal states, and retain results before status records expire.

Retain the data.task_id returned by creation before polling. A successful submission means the task was accepted; generation can still fail later.

Query status

curl --fail-with-body "https://api.musespark.ai/api/v1/openapi/task/status/$MUSESPARK_TASK_ID" \
  -H "Authorization: Bearer $MUSESPARK_API_KEY"

The status endpoint requires a task UUID and permission to read the task. Inspect both the HTTP status and the application's code field.

Wait for a terminal state

Continue with backoff while the state is pending, running, or finalizing. Stop polling on completed, failed, or cancelled. A partial batch result does not mean the parent task is complete.

On failure, inspect data.error or data.message when present. See task lifecycle for state and timestamp definitions.

Save the output

On completion, consume data.result.output_urls and any applicable data.result.batch_results. Use returned URLs exactly as provided. The selected model guide explains the output's model-specific meaning.

Persist the task ID and the results your application needs. Terminal status records with completed_at expire after 30 minutes. Status retention does not establish how long an output URL remains valid.

Resume after a client timeout

A polling timeout does not cancel the existing task. Resume queries with the same task ID. For a creation timeout, reconcile any accepted task and follow the idempotency and retry policy.

Status endpoint reference · Complete polling programs