jpskill.com
🎬 動画AI コミュニティ

vertex-media-generation

Vercel AI SDK Google Vertexプロバイダーを活用し、Imagenで画像生成・編集、Veoで動画生成を行い、メディア生成パイプラインを構築するなど、高度な画像・動画制作ニーズに応えるSkill。

📜 元の英語説明(参考)

Generate images with Imagen and videos with Veo using the Vercel AI SDK Google Vertex provider. Use when the user wants to generate images, edit images (inpainting, outpainting, background swap), generate videos, or build media generation pipelines with @ai-sdk/google-vertex. Covers Imagen 4.0/3.0 and Veo 3.1/3.0/2.0 models.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Vercel AI SDK Google Vertexプロバイダーを活用し、Imagenで画像生成・編集、Veoで動画生成を行い、メディア生成パイプラインを構築するなど、高度な画像・動画制作ニーズに応えるSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o vertex-media-generation.zip https://jpskill.com/download/15536.zip && unzip -o vertex-media-generation.zip && rm vertex-media-generation.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15536.zip -OutFile "$d\vertex-media-generation.zip"; Expand-Archive "$d\vertex-media-generation.zip" -DestinationPath $d -Force; ri "$d\vertex-media-generation.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して vertex-media-generation.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → vertex-media-generation フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Vertex Media Generation

概要

Vercel AI SDK を通じて Google Vertex AI を使用して、画像および動画生成機能を構築します。画像生成および編集(インペインティング、アウトペインティング、背景スワップ)用の Imagen モデルと、オプションでオーディオ付きの動画生成用の Veo モデルをカバーします。統合された ai SDK で @ai-sdk/google-vertex プロバイダーを使用します。

手順

ステップ 1: プロジェクトのセットアップ

npm install ai @ai-sdk/google-vertex
gcloud auth application-default login

デフォルトのプロバイダーインスタンスを使用する(環境変数から GOOGLE_CLOUD_PROJECT を読み取る)か、カスタムのインスタンスを作成します。

import { vertex } from '@ai-sdk/google-vertex';
// または: import { createVertex } from '@ai-sdk/google-vertex';
// const vertex = createVertex({ project: 'my-gcp-project', location: 'us-central1' });

ステップ 2: Imagen で画像を生成する

Vertex 画像モデルで ai パッケージの generateImage を使用します。

import { vertex } from '@ai-sdk/google-vertex';
import { generateImage } from 'ai';

const { image } = await generateImage({
  model: vertex.image('imagen-4.0-generate-001'),
  prompt: '夕暮れ時の未来的な都市景観',
  aspectRatio: '16:9',
});

Imagen は size パラメータをサポートしていません。代わりに aspectRatio を使用してください。サポートされている比率: 1:13:44:39:1616:9

利用可能な Imagen モデル:

モデル 速度 品質
imagen-4.0-ultra-generate-001 低速 最高
imagen-4.0-generate-001 中速
imagen-4.0-fast-generate-001 高速 良好
imagen-3.0-generate-002 中速
imagen-3.0-fast-generate-001 高速 良好

プロバイダーオプションで生成を構成します。

const { image } = await generateImage({
  model: vertex.image('imagen-4.0-generate-001'),
  prompt: 'プロフェッショナルな顔写真ポートレート',
  aspectRatio: '1:1',
  providerOptions: {
    vertex: {
      negativePrompt: 'ぼやけ、低品質、歪み',
      personGeneration: 'allow_adult',
      safetySetting: 'block_medium_and_above',
      addWatermark: true,
    },
  },
});

プロバイダーオプション: negativePrompt (要素を除外)、personGeneration (allow_adult | allow_all | dont_allow)、safetySetting (block_low_and_above | block_medium_and_above | block_only_high | block_none)、addWatermark (boolean、デフォルトは true)、storageUri (GCS パス)。

ステップ 3: Imagen で画像を編集する

インペインティング、アウトペインティング、および背景スワップには imagen-3.0-capability-001 を使用します。ソース画像とマスク(白いピクセル = 編集する領域)を提供します。

import { generateImage } from 'ai';
import fs from 'fs';

const sourceImage = fs.readFileSync('./photo.png');
const mask = fs.readFileSync('./mask.png');

const { images } = await generateImage({
  model: vertex.image('imagen-3.0-capability-001'),
  prompt: {
    text: '草の上に座っているゴールデンレトリバーを追加',
    images: [sourceImage],
    mask,
  },
  providerOptions: {
    vertex: {
      edit: {
        mode: 'EDIT_MODE_INPAINT_INSERTION',
        maskMode: 'MASK_MODE_USER_PROVIDED',
        baseSteps: 50,
        maskDilation: 0.01,
      },
    },
  },
});

編集モード: EDIT_MODE_INPAINT_INSERTION (オブジェクトを追加)、EDIT_MODE_INPAINT_REMOVAL (オブジェクトを削除)、EDIT_MODE_OUTPAINT (キャンバスを拡張)、EDIT_MODE_BGSWAP (背景を置き換え)、EDIT_MODE_PRODUCT_IMAGE (商品写真)、EDIT_MODE_CONTROLLED_EDITING (スタイルの転送)。baseSteps パラメータ (35-75) は品質を制御します。値を大きくすると、より良い結果が得られますが、時間がかかります。

ステップ 4: Veo で動画を生成する

動画生成には experimental_generateVideo を使用します。動画生成は非同期であり、数分かかる場合があります。

import { vertex } from '@ai-sdk/google-vertex';
import { experimental_generateVideo as generateVideo } from 'ai';

const { video } = await generateVideo({
  model: vertex.video('veo-3.1-generate-001'),
  prompt: '熱帯魚がいるサンゴ礁の空撮ドローンショット',
  aspectRatio: '16:9',
  resolution: '1920x1080',
  duration: 8,
});

利用可能な Veo モデル:

モデル オーディオ
veo-3.1-generate-001 はい
veo-3.1-fast-generate-001 はい
veo-3.0-generate-001 はい
veo-3.0-fast-generate-001 はい
veo-2.0-generate-001 いいえ

プロバイダーオプションで構成します。

import { vertex } from '@ai-sdk/google-vertex';
import { experimental_generateVideo as generateVideo } from 'ai';

const { video } = await generateVideo({
  model: vertex.video('veo-3.1-generate-001'),
  prompt: '花が咲くタイムラプス',
  aspectRatio: '16:9',
  providerOptions: {
    vertex: {
      generateAudio: true,
      personGeneration: 'allow_adult',
      negativePrompt: 'ぼやけ、手ぶれ、低解像度',
      pollIntervalMs: 5000,
      pollTimeoutMs: 600000,
    },
  },
});

プロバイダーオプション: generateAudio (boolean)、personGenerationnegativePromptgcsOutputDirectory (GCS URI)、referenceImages (スタイルのガイダンス)、pollIntervalMs (チェック間隔)、pollTimeoutMs (最大待機時間、長い動画の場合はデフォルトで 10 分)。

例 1: 商品写真パイプライン

ユーザーリクエスト: 「セラミックマグのeコマースリスティング用の商品写真を生成する」

実行されたアクション:


import { vertex } from '@ai-sdk/google-vertex';
import { generateImage } from 'ai';
import fs from 'fs';

const backgrounds = [
  '柔らかな自然光のあるミニマリストの白い大理石のカウンタートップ',
  '朝の日差しとクロワッサンがある居心地の良い朝食テーブル',
  'ノートパソコンとノートがあるモダンなオフィスデスク、浅い被写界深度',
];

for (const [i, scene] of backgrounds.entries()) {
  const { image } = await generateImage({
    model: vertex.image('imagen-4.0-generate-001'),
    prompt: `手作りのセラミックコーヒーマグ、アースカラーの釉薬、${scene}のプロフェッショナルな商品写真`,
    aspectRatio: '1:1',
    providerOptions: {
      vertex: {
        negativePrompt: 'テキスト、透かし、ロゴ、ぼやけ、彩度が高すぎる',
        addWatermark: false,
      },
    },
  });

  fs.writeFileSync(`mug-scene-${i + 1}.png`, Buffer.from(image.base64, 'base64'));


(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Vertex Media Generation

Overview

Build image and video generation features using Google Vertex AI through the Vercel AI SDK. Covers Imagen models for image generation and editing (inpainting, outpainting, background swap) and Veo models for video generation with optional audio. Uses the @ai-sdk/google-vertex provider with the unified ai SDK.

Instructions

Step 1: Set up the project

npm install ai @ai-sdk/google-vertex
gcloud auth application-default login

Use the default provider instance (reads GOOGLE_CLOUD_PROJECT from env), or create a custom one:

import { vertex } from '@ai-sdk/google-vertex';
// Or: import { createVertex } from '@ai-sdk/google-vertex';
// const vertex = createVertex({ project: 'my-gcp-project', location: 'us-central1' });

Step 2: Generate images with Imagen

Use generateImage from the ai package with a Vertex image model:

import { vertex } from '@ai-sdk/google-vertex';
import { generateImage } from 'ai';

const { image } = await generateImage({
  model: vertex.image('imagen-4.0-generate-001'),
  prompt: 'A futuristic cityscape at sunset',
  aspectRatio: '16:9',
});

Imagen does NOT support the size parameter. Use aspectRatio instead. Supported ratios: 1:1, 3:4, 4:3, 9:16, 16:9.

Available Imagen models:

Model Speed Quality
imagen-4.0-ultra-generate-001 Slow Highest
imagen-4.0-generate-001 Medium High
imagen-4.0-fast-generate-001 Fast Good
imagen-3.0-generate-002 Medium High
imagen-3.0-fast-generate-001 Fast Good

Configure generation with provider options:

const { image } = await generateImage({
  model: vertex.image('imagen-4.0-generate-001'),
  prompt: 'Professional headshot portrait',
  aspectRatio: '1:1',
  providerOptions: {
    vertex: {
      negativePrompt: 'blurry, low-quality, distorted',
      personGeneration: 'allow_adult',
      safetySetting: 'block_medium_and_above',
      addWatermark: true,
    },
  },
});

Provider options: negativePrompt (exclude elements), personGeneration (allow_adult | allow_all | dont_allow), safetySetting (block_low_and_above | block_medium_and_above | block_only_high | block_none), addWatermark (boolean, default true), storageUri (GCS path).

Step 3: Edit images with Imagen

Use imagen-3.0-capability-001 for inpainting, outpainting, and background swap. Provide the source image and a mask (white pixels = area to edit):

import { generateImage } from 'ai';
import fs from 'fs';

const sourceImage = fs.readFileSync('./photo.png');
const mask = fs.readFileSync('./mask.png');

const { images } = await generateImage({
  model: vertex.image('imagen-3.0-capability-001'),
  prompt: {
    text: 'Add a golden retriever sitting on the grass',
    images: [sourceImage],
    mask,
  },
  providerOptions: {
    vertex: {
      edit: {
        mode: 'EDIT_MODE_INPAINT_INSERTION',
        maskMode: 'MASK_MODE_USER_PROVIDED',
        baseSteps: 50,
        maskDilation: 0.01,
      },
    },
  },
});

Edit modes: EDIT_MODE_INPAINT_INSERTION (add objects), EDIT_MODE_INPAINT_REMOVAL (remove objects), EDIT_MODE_OUTPAINT (extend canvas), EDIT_MODE_BGSWAP (replace background), EDIT_MODE_PRODUCT_IMAGE (product photography), EDIT_MODE_CONTROLLED_EDITING (style transfer). The baseSteps parameter (35-75) controls quality: higher values produce better results but take longer.

Step 4: Generate videos with Veo

Use experimental_generateVideo for video generation. Video generation is asynchronous and may take several minutes:

import { vertex } from '@ai-sdk/google-vertex';
import { experimental_generateVideo as generateVideo } from 'ai';

const { video } = await generateVideo({
  model: vertex.video('veo-3.1-generate-001'),
  prompt: 'Aerial drone shot of a coral reef with tropical fish',
  aspectRatio: '16:9',
  resolution: '1920x1080',
  duration: 8,
});

Available Veo models:

Model Audio
veo-3.1-generate-001 Yes
veo-3.1-fast-generate-001 Yes
veo-3.0-generate-001 Yes
veo-3.0-fast-generate-001 Yes
veo-2.0-generate-001 No

Configure with provider options:

const { video } = await generateVideo({
  model: vertex.video('veo-3.1-generate-001'),
  prompt: 'Time-lapse of a flower blooming',
  aspectRatio: '16:9',
  providerOptions: {
    vertex: {
      generateAudio: true,
      personGeneration: 'allow_adult',
      negativePrompt: 'blurry, shaky, low-resolution',
      pollIntervalMs: 5000,
      pollTimeoutMs: 600000,
    },
  },
});

Provider options: generateAudio (boolean), personGeneration, negativePrompt, gcsOutputDirectory (GCS URI), referenceImages (style guidance), pollIntervalMs (check interval), pollTimeoutMs (max wait, default 10 min for long videos).

Examples

Example 1: Product photography pipeline

User request: "Generate product photos for an e-commerce listing of a ceramic mug"

Actions taken:

import { vertex } from '@ai-sdk/google-vertex';
import { generateImage } from 'ai';
import fs from 'fs';

const backgrounds = [
  'Minimalist white marble countertop with soft natural lighting',
  'Cozy breakfast table with morning sunlight and croissants',
  'Modern office desk with laptop and notebook, shallow depth of field',
];

for (const [i, scene] of backgrounds.entries()) {
  const { image } = await generateImage({
    model: vertex.image('imagen-4.0-generate-001'),
    prompt: `Professional product photo of a handmade ceramic coffee mug, earth-tone glaze, ${scene}`,
    aspectRatio: '1:1',
    providerOptions: {
      vertex: {
        negativePrompt: 'text, watermark, logo, blurry, oversaturated',
        addWatermark: false,
      },
    },
  });

  fs.writeFileSync(`mug-scene-${i + 1}.png`, Buffer.from(image.base64, 'base64'));
  console.log(`Saved mug-scene-${i + 1}.png`);
}

Expected output: Three 1:1 product images saved as PNG files, each showing the mug in a different setting.

Example 2: Video ad generation with audio

User request: "Create a short video ad for a hiking app launch"

Actions taken:

import { vertex } from '@ai-sdk/google-vertex';
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'fs';

const { video } = await generateVideo({
  model: vertex.video('veo-3.1-generate-001'),
  prompt: `Cinematic drone shot following a solo hiker ascending a mountain trail
at golden hour. Camera starts low behind the hiker and rises to reveal a
panoramic vista of snow-capped peaks. Style: epic, aspirational, warm color
grading. Text overlay space at the top third of the frame.`,
  aspectRatio: '9:16',
  resolution: '1080x1920',
  duration: 8,
  providerOptions: {
    vertex: {
      generateAudio: true,
      negativePrompt: 'shaky camera, low quality, overexposed, urban elements',
      pollTimeoutMs: 600000,
    },
  },
});

fs.writeFileSync('hiking-app-ad.mp4', Buffer.from(video.base64, 'base64'));
console.log('Saved hiking-app-ad.mp4');

Expected output: An 8-second vertical video with generated audio, saved as MP4.

Example 3: Image editing — background swap

User request: "Replace the background of this product photo with a beach scene"

Actions taken:

import { vertex } from '@ai-sdk/google-vertex';
import { generateImage } from 'ai';
import fs from 'fs';

const sourceImage = fs.readFileSync('./product-original.png');
const mask = fs.readFileSync('./background-mask.png');

const { images } = await generateImage({
  model: vertex.image('imagen-3.0-capability-001'),
  prompt: {
    text: 'Sandy tropical beach at sunset with palm trees and calm ocean waves',
    images: [sourceImage],
    mask,
  },
  providerOptions: {
    vertex: {
      edit: {
        mode: 'EDIT_MODE_BGSWAP',
        maskMode: 'MASK_MODE_USER_PROVIDED',
        baseSteps: 60,
      },
    },
  },
});

fs.writeFileSync('product-beach-bg.png', Buffer.from(images[0].base64, 'base64'));
console.log('Saved product-beach-bg.png');

Expected output: The original product preserved with a new beach background.

Guidelines

  • Always use aspectRatio instead of size for Imagen models — size is not supported.
  • Use imagen-4.0-generate-001 as the default for new image generation. Use imagen-3.0-capability-001 only for editing operations.
  • Set pollTimeoutMs to at least 600000 (10 min) for Veo video generation — it can take several minutes, especially for higher resolutions or longer durations.
  • Use negativePrompt to refine outputs: list specific artifacts to avoid (blurry, distorted, watermark) rather than vague terms.
  • For production pipelines, specify storageUri (images) or gcsOutputDirectory (videos) to write directly to Cloud Storage instead of handling base64 in memory.
  • Video generation with Veo is experimental (experimental_generateVideo). The API may change between SDK versions.
  • Models with fast in the name trade quality for speed — use them for drafts and iteration, switch to standard models for final output.
  • personGeneration defaults to blocking people. Set to allow_adult or allow_all when generating content that intentionally includes people.
  • GCP billing applies to all Vertex AI media generation. Imagen ultra and Veo 3.1 cost more than their standard/fast counterparts.