mcpField
A
ai-video-gen

ai-video-gen

github.com/heygen-comクリエイティブ・メディア526987 回インストール15 週間前に更新
リポジトリ

ai-video-gen について

ai-video-gen は HeyGen API を使い、テキストプロンプトから動画を生成するスキルです。テキストからの生成や画像を使った動画制作向けで、複数の生成プロバイダー、アスペクト比、画像指定に対応しています。

主な機能

  1. 01テキストプロンプトから動画を生成
  2. 02複数の生成プロバイダーに対応
  3. 03アスペクト比の設定
  4. 04参照画像と末尾フレーム画像の指定
  5. 05ジョブの状態確認と動画 URL の取得

活用シーン

  1. 01説明文から動画を制作
  2. 02商品写真を動画化
  3. 03SNS 向けの縦型動画を生成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/heygen-com/skills --skill ai-video-gen

インストール後、Claude Code で/ai-video-genを入力して読み込まれたか確認します。

詳細

動画生成(HeyGen API)

テキストプロンプトから AI 動画を生成します。複数のプロバイダー(VEO 3.1、Kling、Sora、Runway、Seedance)、設定可能なアスペクト比、画像から動画を生成するためのオプションの参照画像に対応しています。

認証

すべてのリクエストで X-Api-Key ヘッダーが必要です。HEYGEN_API_KEY 環境変数を設定してください。

curl -X POST "https://api.heygen.com/v1/workflows/executions" \
  -H "X-Api-Key: $HEYGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"workflow_type": "GenerateVideoNode", "input": {"prompt": "A drone shot flying over a coastal city at sunset"}}'

デフォルトのワークフロー

  1. workflow_type: "GenerateVideoNode" とプロンプトを指定して POST /v1/workflows/executions を呼び出します
  2. レスポンスで execution_id を受け取ります
  3. ステータスが completed になるまで、10 秒ごとに GET /v1/workflows/executions/{id} をポーリングします
  4. 出力から返された video_url を使用します

動画生成の実行

エンドポイント

POST https://api.heygen.com/v1/workflows/executions

リクエストフィールド
フィールド型必須説明
workflow_typestringY"GenerateVideoNode" を指定する必要があります
input.promptstringY生成する動画のテキストによる説明
input.providerstring動画生成プロバイダー(デフォルト:"veo_3_1")。下記のプロバイダーを参照してください。
input.aspect_ratiostringアスペクト比(デフォルト:"16:9")。一般的な値:"16:9"、"9:16"、"1:1"
input.reference_image_urlstring画像から動画を生成するための参照画像 URL
input.tail_image_urlstring最終フレームのガイダンス用の末尾画像 URL
input.configobjectプロバイダー固有の設定の上書き
プロバイダー
プロバイダー値説明
VEO 3.1"veo_3_1"Google VEO 3.1(デフォルト、最高品質)
VEO 3.1 Fast"veo_3_1_fast"より高速な VEO 3.1 バリアント
VEO 3"veo3"Google VEO 3
VEO 3 Fast"veo3_fast"より高速な VEO 3 バリアント
VEO 2"veo2"Google VEO 2
Kling Pro"kling_pro"Kling Pro モデル
Kling V2"kling_v2"Kling V2 モデル
Sora V2"sora_v2"OpenAI Sora V2
Sora V2 Pro"sora_v2_pro"OpenAI Sora V2 Pro
Runway Gen-4"runway_gen4"Runway Gen-4
Seedance Lite"seedance_lite"Seedance Lite
Seedance Pro"seedance_pro"Seedance Pro
LTX Distilled"ltx_distilled"LTX Distilled(最速)
curl
curl -X POST "https://api.heygen.com/v1/workflows/executions" \
  -H "X-Api-Key: $HEYGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workflow_type": "GenerateVideoNode",
    "input": {
      "prompt": "A drone shot flying over a coastal city at golden hour, cinematic lighting",
      "provider": "veo_3_1",
      "aspect_ratio": "16:9"
    }
  }'
TypeScript
interface GenerateVideoInput {
  prompt: string;
  provider?: string;
  aspect_ratio?: string;
  reference_image_url?: string;
  tail_image_url?: string;
  config?: Record<string, any>;
}

interface ExecuteResponse {
  data: {
    execution_id: string;
    status: "submitted";
  };
}

async function generateVideo(input: GenerateVideoInput): Promise<string> {
  const response = await fetch("https://api.heygen.com/v1/workflows/executions", {
    method: "POST",
    headers: {
      "X-Api-Key": process.env.HEYGEN_API_KEY!,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      workflow_type: "GenerateVideoNode",
      input,
    }),
  });

  const json: ExecuteResponse = await response.json();
  return json.data.execution_id;
}
Python
import requests
import os

def generate_video(
    prompt: str,
    provider: str = "veo_3_1",
    aspect_ratio: str = "16:9",
    reference_image_url: str | None = None,
    tail_image_url: str | None = None,
) -> str:
    payload = {
        "workflow_type": "GenerateVideoNode",
        "input": {
            "prompt": prompt,
            "provider": provider,
            "aspect_ratio": aspect_ratio,
        },
    }

    if reference_image_url:
        payload["input"]["reference_image_url"] = reference_image_url
    if tail_image_url:
        payload["input"]["tail_image_url"] = tail_image_url

    response = requests.post(
        "https://api.heygen.com/v1/workflows/executions",
        headers={
            "X-Api-Key": os.environ["HEYGEN_API_KEY"],
            "Content-Type": "application/json",
        },
        json=payload,
    )

    data = response.json()
    return data["data"]["execution_id"]
レスポンス形式
{
  "data": {
    "execution_id": "node-gw-v1d2e3o4",
    "status": "submitted"
  }
}

ステータスの確認

エンドポイント

GET https://api.heygen.com/v1/workflows/executions/{execution_id}

curl
curl -X GET "https://api.heygen.com/v1/workflows/executions/node-gw-v1d2e3o4" \
  -H "X-Api-Key: $HEYGEN_API_KEY"
レスポンス形式(完了時)
{
  "data": {
    "execution_id": "node-gw-v1d2e3o4",
    "status": "completed",
    "output": {
      "video": {
        "video_url": "https://resource.heygen.ai/generated/video.mp4",
        "video_id": "abc123"
      },
      "asset_id": "asset-xyz789"
    }
  }
}

完了までのポーリング

async function generateVideoAndWait(
  input: GenerateVideoInput,
  maxWaitMs = 600000,
  pollIntervalMs = 10000
): Promise<{ video_url: string; video_id: string; asset_id: string }> {
  const executionId = await generateVideo(input);
  console.log(`Submitted video generation: ${executionId}`);

  const startTime = Date.now();
  while (Date.now() - startTime < maxWaitMs) {
    const response = await fetch(
      `https://api.heygen.com/v1/workflows/executions/${executionId}`,
      { headers: { "X-Api-Key": process.env.HEYGEN_API_KEY! } }
    );
    const { data } = await response.json();

    switch (data.status) {
      case "completed":
        return {
          video_url: data.output.video.video_url,
          video_id: data.output.video.video_id,
          asset_id: data.output.asset_id,
        };
      case "failed":
        throw new Error(data.error?.message || "Video generation failed");
      case "not_found":
        throw new Error("Workflow not found");
      default:
        await new Promise((r) => setTimeout(r, pollIntervalMs));
    }
  }

  throw new Error("Video generation timed out");
}

使用例

シンプルなテキストから動画への変換
curl -X POST "https://api.heygen.com/v1/workflows/executions" \
  -H "X-Api-Key: $HEYGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workflow_type": "GenerateVideoNode",
    "input": {
      "prompt": "A person walking through a sunlit park, shallow depth of field"
    }
  }'
画像から動画への変換
{
  "workflow_type": "GenerateVideoNode",
  "input": {
    "prompt": "Animate this product photo with a slow zoom and soft particle effects",
    "reference_image_url": "https://example.com/product-photo.png",
    "provider": "kling_pro"
  }
}
ソーシャルメディア向けの縦型フォーマット
{
  "workflow_type": "GenerateVideoNode",
  "input": {
    "prompt": "A trendy coffee shop interior, camera slowly panning across the counter",
    "aspect_ratio": "9:16",
    "provider": "veo_3_1"
  }
}
LTX による高速生成
{
  "workflow_type": "GenerateVideoNode",
  "input": {
    "prompt": "Abstract colorful shapes morphing and flowing",
    "provider": "ltx_distilled"
  }
}

ベストプラクティス

  1. プロンプトは具体的に記述します — カメラの動き、照明、スタイル、雰囲気の詳細を含めます
  2. 最高品質を求める場合は VEO 3.1 をデフォルトにします。速度を重視する場合は ltx_distilled または veo3_fast を使用します
  3. 画像から動画を生成する場合は参照画像を使用します — 商品写真や静止画のアニメーション化に最適です
  4. 動画生成は最も時間がかかるワークフローです — 最大 5 分かかる場合があるため、10 秒ごとにポーリングします
  5. アスペクト比は重要です — ソーシャルメディアのストーリーやリールには 9:16、横長には 16:9、正方形には 1:1 を使用します
  6. 出力には asset_id が含まれます — 他の HeyGen ワークフローで生成した動画を参照する際に使用します
  7. 出力 URL は一時的なものです — 生成した動画は速やかにダウンロードまたは保存してください

コメント