Sound effects generate in a few seconds. Poll this endpoint until the status flips to completed. If you'd rather not poll, set a webhook URL when you create the sound effect and we'll deliver the result to you — see Webhooks.
async function waitForSoundEffect(id, apiKey) { while (true) { const res = await fetch(`https://pub.finetuning.ai/v1/sound-effects/${id}`, { headers: { 'X-API-Key': apiKey }, }); const { data } = await res.json(); if (data.status === 'completed') return data; if (data.status === 'failed') throw new Error(data.errorMessage); // Wait 2 seconds before polling again await new Promise(r => setTimeout(r, 2000)); }}