vertex-media-generation

使用 Vercel AI SDK 的 Google Vertex 提供程序,通过 Imagen 生成图像、通过 Veo 生成视频。适用于需要生成图像、编辑图像(内绘、外绘、背景替换)、生成视频,或使用 @ai-sdk/google-vertex 构建媒体生成流水线的场景。支持 Imagen 4.0/3.0 和 Veo 3.1/3.0/2.0 模型。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "vertex-media-generation":https://skillpi.com/zh/skills/deepskill-2018e1e452c05c1b3d9185e0a8ccdb3723607ca08604799272cc4d55950019db。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

使用 Vercel AI SDK 的 Google Vertex 提供程序,通过 Imagen 生成图像、通过 Veo 生成视频。适用于需要生成图像、编辑图像(内绘、外绘、背景替换)、生成视频,或使用 @ai-sdk/google-vertex 构建媒体生成流水线的场景。支持 Imagen 4.0/3.0 和 Veo 3.1/3.0/2.0 模型。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: vertex-media-generation
description: >-
  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.
license: Apache-2.0
compatibility: "Node.js 18+, npm/pnpm/yarn, @ai-sdk/google-vertex and ai packages, Google Cloud project with Vertex AI API enabled"
metadata:
  author: terminal-skills
  version: "1.0.0"
  category: data-ai
  tags: ["vertex-ai", "imagen", "veo", "image-generation", "video-generation"]

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.

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值92/100

亮点

  • 提供基于 Google Vertex AI 的高质量图像和视频生成能力,覆盖 Imagen 和 Veo 全系列模型
  • 支持图像编辑(内绘、外绘、背景替换)和视频生成,适用于电商、广告、内容创作等高频商业场景
  • 具备端到端流水线构建能力,满足专业用户和开发者的深度集成需求
触发精准95/100

亮点

  • 触发描述清晰完整,明确覆盖图像生成、编辑、视频生成及 SDK 集成等核心场景
  • 模型版本和参数边界定义准确,避免与其他媒体生成工具混淆
结构规范94/100

亮点

  • 文档结构完整,分步骤说明清晰,包含三个高质量端到端示例
  • frontmatter 信息齐全,兼容性说明明确,代码示例可直接执行
执行可靠91/100

亮点

  • 工具来源和依赖明确,参数使用符合官方规范(如 aspectRatio 替代 size)
  • 覆盖异步操作超时、GCS 输出、安全设置等关键异常处理场景
  • 提供生产环境最佳实践建议(如 storageUri、pollTimeoutMs 配置)
证据可验 (前四项均值)93/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。