Async jobs
Long-running work (video, image, songs, audio translation, phone calls) runs in the background; start it, wait for it, download the result.
Some work takes longer than an HTTP request should: rendering a video, a song, translating a long recording, a phone call. Those endpoints answer at once with an id and do the work in the background.
The life of a job#
| Status | Meaning |
|---|---|
queued / pending | accepted, waiting for capacity |
processing / running | in progress |
completed | done: the result URL (output_url, audio_url, …) is set |
failed | it did not work; error says why and the credits are refunded |
cancelled | you cancelled it |
Credits are reserved when the job starts and the unused part is returned if it fails or is cancelled.
Wait for it#
Poll the status endpoint with backoff (start at 2 seconds, grow to about 15) or let the SDK do it. For phone calls, a webhook (call.ended) is better than polling.
# start a video
curl -X POST https://api.voicemint.io/api/v1/generate/video \
-H "Authorization: Bearer $VOICEMINT_API_KEY" -H "Content-Type: application/json" \
-d '{"prompt": "a paper boat sailing down a rainy street", "duration": 5, "aspect_ratio": "9:16"}'
# poll until "completed", then download output_url
curl https://api.voicemint.io/api/v1/generate/GENERATION_ID/status \
-H "Authorization: Bearer $VOICEMINT_API_KEY"The SDK helpers per product:
| Work | Start | Wait | Result |
|---|---|---|---|
| Video, image | video.generate, image.generate | jobs.wait | jobs.download(output_url) |
| Songs | music.songs.create | music.songs.wait | jobs.download(audio_url) |
| Audio translation | translation.create_audio_job | translation.wait_job | translation.job_result |
| Phone calls | calls.create | calls.wait | the call record (transcript, summary) |
A wait that times out does not stop the job; wait again later or cancel it (POST /generate/{id}/cancel).
Downloads#
Result URLs are either API URLs (send your key) or signed storage links that expire (fetch them without the key, and do not store them: store the id and fetch a fresh link). jobs.download handles both and never sends your key to a storage host.