AGTCloud API Docs
GuidesAPI ReferenceIntegrations and resourcesUpdate and help
Video generationPlatform Video Generations

Retrieve a video

Retrieve a video task with the platform Video Generations API.

Use the task ID returned by the create endpoint to retrieve status, video output, and metadata. Stop polling when the task reaches succeeded or failed.

GET/v1/video/generations/{task_id}

Use the Task ID returned by the creation interface to query the current status and result of video tasks. Polling should stop once a task enters succeeded or failed.

This interface uses the task path and status structure of the Video Generations platform and is not equivalent to the Video ID query interface of OpenAI Videos

Authorization

bearerAuth
AuthorizationBearer <token>

Use Bearer your-api-key in the Authorization Header.

In: header

Path Parameters

task_id*string

The Task ID returned when creating platform video tasks.

Length1 <= length

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

Poll task status

Video generation is asynchronous. After submitting a task, use the following polling intervals to balance result latency and request frequency:

  1. Wait 2–3 seconds after submitting the task.
  2. Poll every 5 seconds during the first 30 seconds.
  3. Poll every 10 seconds from 30 seconds to 2 minutes.
  4. Poll every 30 seconds after 2 minutes.
  5. Set an overall timeout of 5–10 minutes and stop immediately when the task reaches succeeded or failed.

JavaScript polling example

async function pollVideoStatus(taskId, maxAttempts = 30) {
  const apiOrigin = 'https://api.agtcloud.cn';
  const headers = {
    Authorization: 'Bearer your-api-key',
  };

  await new Promise((resolve) => setTimeout(resolve, 3000));

  for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
    const response = await fetch(
      `${apiOrigin}/v1/video/generations/${encodeURIComponent(taskId)}`,
      { headers },
    );

    if (!response.ok) {
      throw new Error(`Query failed with HTTP ${response.status}`);
    }

    const result = await response.json();

    if (result.status === 'succeeded') {
      return result;
    }

    if (result.status === 'failed') {
      throw new Error(result.error?.message ?? 'Video generation failed');
    }

    const delay = attempt < 6 ? 5000 : attempt < 12 ? 10000 : 30000;
    await new Promise((resolve) => setTimeout(resolve, delay));
  }

  throw new Error('Video task polling timed out');
}

pollVideoStatus('TASK_ID').then(console.log).catch(console.error);