Get started

Long-running jobs

Start work that takes minutes, track it, and collect the result.

Dubbing a video, translating a batch of documents or analyzing an image takes longer than an HTTP request should stay open. These endpoints start a job and return its ID straight away. You then poll the job until it finishes.

The pattern

Start the job

The response comes back immediately with a job ID and its first status. Credits are checked at this point; if there aren't enough, you get a 402 and nothing starts.

POST /v1/galaxy/translate-video/process-log/run
Response
{
  "jobId": "9b1f6c2e…",
  "status": "queued",
  "processType": "VIDEO_TO_SPEECH_TRANSLATION"
}

Poll until it finishes

GET /v1/galaxy/translate-video/process-log/run/{id}
Response (while running)
{
  "jobId": "9b1f6c2e…",
  "status": "running",
  "stage": "TRANSCREATION-ENGINE",
  "progress": 55,
  "result": null,
  "error": null
}

Read the result

When status is succeeded, result holds the output and credits shows what the job used. If it's failed, error says why.

Job statuses

Video Dubbing jobs use these statuses:

statusMeaning
queuedAccepted and waiting to start.
runningIn progress. stage and progress (0 to 100) show how far it has got.
succeededFinished. Collect the result.
failedStopped with an error. error says why. You can retry it from the failed step.
cancelledStopped at your request.

Video Dubbing jobs can be cancelled with DELETE /v1/galaxy/translate-video/process-log/run/{jobId}.

Polling well

poll.ts
async function waitForJob(jobId: string) {
  const url = `https://universe-api.vitra.ai/v1/galaxy/translate-video/process-log/run/${jobId}`;
  let delay = 5_000;
  for (;;) {
    const res = await fetch(url, { headers: { 'x-api-key': process.env.VITRA_API_KEY! } });
    if (res.status === 429) {
      await sleep(Number(res.headers.get('retry-after') ?? 60) * 1000);
      continue;
    }
    const job = await res.json();
    if (['succeeded', 'failed', 'cancelled'].includes(job.status)) return job;
    await sleep(delay);
    delay = Math.min(delay * 1.5, 30_000);
  }
}

const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
  • Start at about 5 seconds between polls and slow down to around 30 seconds for long jobs.
  • Respect 429 and Retry-After. Polls count toward the key's rate limit.
  • Store the job ID as soon as you get it, so a restart of your system can pick the job up again.

Each product's job endpoints

Every product that runs jobs follows this shape, but the paths and status fields are its own:

Webhooks

Only the Blog API sends webhooks so far: register one to be told when a post, a translation, a recording or an Autopilot run finishes. The other products don't send webhooks yet, and the app's live-progress websockets don't accept API keys, so polling is the supported way to track their jobs.

Last updated on

On this page