AGTCloud API Docs
ガイドAPIリファレンス連携とリソース更新とヘルプ
動画生成Platform Video Generations

動画を取得

Platform Video Generations API を使用して動画タスクを取得します。

作成 API が返した Task ID を使用して、ステータス、動画の結果、メタデータを取得します。タスクが succeeded または failed になったらポーリングを停止してください。

GET/v1/video/generations/{task_id}

作成 API が返した Task ID を使用して、動画タスクの現在のステータスと結果を取得します。タスクが succeeded または failed になったらポーリングを停止してください。

この API は Platform Video Generations のタスクパスとステータス構造を使用します。OpenAI Videos の Video ID 取得 API とは異なります。

認証

bearerAuth
認証Bearer <token>

Authorization Header に Bearer your-api-key を指定します。

指定位置: header

パスパラメーター

task_id*string

Platform 動画タスクの作成時に返された Task ID です。

長さ1 <= length

レスポンスボディ

application/json

application/json

application/json

application/json

application/json

application/json

タスクステータスをポーリングする

動画生成は非同期で処理されます。タスクを送信した後は、結果取得までの時間とリクエスト頻度のバランスを保つため、次の間隔で取得できます。

  1. タスク送信後、最初に 2~3 秒待機します。
  2. 最初の 30 秒間は 5 秒ごとに取得します。
  3. 30 秒から 2 分までは 10 秒ごとに取得します。
  4. 2 分経過後は 30 秒ごとに取得します。
  5. 全体のタイムアウトを 5~10 分に設定し、タスクが succeeded または failed になったら直ちに停止します。

JavaScript ポーリング例

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(`HTTP ${response.status} で取得に失敗しました`);
    }

    const result = await response.json();

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

    if (result.status === 'failed') {
      throw new Error(result.error?.message ?? '動画生成に失敗しました');
    }

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

  throw new Error('動画タスクのポーリングがタイムアウトしました');
}

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