Gemini API の Veo 3.1 で動画を生成する

Veo 3.1 は、高忠実度の 8 秒間の 720p、1080p、または 4K の動画を生成する Google の最先端モデルです。驚くほどリアルな映像とネイティブに生成された音声が特徴です。このモデルには、Gemini API を使用してプログラムでアクセスできます。使用可能な Veo モデル バリエーションの詳細については、モデル バージョンをご覧ください。

Veo 3.1 は、幅広いビジュアル スタイルと映画的スタイルに優れており、いくつかの新機能が導入されています。

  • 縦向き動画: 横向き(16:9)と縦向き(9:16)の動画を選択します。
  • 動画の拡張: 以前に Veo を使用して生成された動画を拡張します。
  • フレーム固有の生成: 最初と最後のフレームを指定して動画を生成します。
  • 画像ベースの指示: 最大 3 つの参照画像を使用して、生成される動画のコンテンツをガイドします。

動画生成用の効果的なテキスト プロンプトの作成方法については、Veo プロンプト ガイドをご覧ください。

テキストから動画を生成する

会話、映画のようなリアリズム、クリエイティブなアニメーションを含む動画を生成する方法については、次の例をご覧ください。

Python

import time
from google import genai
from google.genai import types

client = genai.Client()

prompt = """A close up of two people staring at a cryptic drawing on a wall, torchlight flickering.
A man murmurs, 'This must be it. That's the secret code.' The woman looks at him and whispering excitedly, 'What did you find?'"""

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the generated video.
generated_video = operation.response.generated_videos[0]
client.files.download(file=generated_video.video)
generated_video.video.save("dialogue_example.mp4")
print("Generated video saved to dialogue_example.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = `A close up of two people staring at a cryptic drawing on a wall, torchlight flickering.
A man murmurs, 'This must be it. That's the secret code.' The woman looks at him and whispering excitedly, 'What did you find?'`;

let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the generated video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "dialogue_example.mp4",
});
console.log(`Generated video saved to dialogue_example.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    prompt := `A close up of two people staring at a cryptic drawing on a wall, torchlight flickering.
    A man murmurs, 'This must be it. That's the secret code.' The woman looks at him and whispering excitedly, 'What did you find?'`

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
        nil,
        nil,
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
    log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the generated video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "dialogue_example.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

Java

import com.google.genai.Client;
import com.google.genai.types.GenerateVideosOperation;
import com.google.genai.types.Video;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

class GenerateVideoFromText {
  public static void main(String[] args) throws Exception {
    Client client = new Client();

    String prompt = "A close up of two people staring at a cryptic drawing on a wall, torchlight flickering.\n" +
"A man murmurs, 'This must be it. That's the secret code.' The woman looks at him and whispering excitedly, 'What did you find?'";

    GenerateVideosOperation operation =
        client.models.generateVideos("veo-3.1-generate-preview", prompt, null, null);

    // Poll the operation status until the video is ready.
    while (!operation.done().isPresent() || !operation.done().get()) {
      System.out.println("Waiting for video generation to complete...");
      Thread.sleep(10000);
      operation = client.operations.getVideosOperation(operation, null);
    }

    // Download the generated video.
    Video video = operation.response().get().generatedVideos().get().get(0).video().get();
    Path path = Paths.get("dialogue_example.mp4");
    client.files.download(video, path.toString(), null);
    if (video.videoBytes().isPresent()) {
      Files.write(path, video.videoBytes().get());
      System.out.println("Generated video saved to dialogue_example.mp4");
    }
  }
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "prompt": "A close up of two people staring at a cryptic drawing on a wall, torchlight flickering. A man murmurs, \"This must be it. That'\''s the secret code.\" The woman looks at him and whispering excitedly, \"What did you find?\""
      }
    ]
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o dialogue_example.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 5 seconds before checking again.
  sleep 10
done

アスペクト比を制御する

Veo 3.1 では、横向き(16:9、デフォルト設定)または縦向き(9:16)の動画を作成できます。aspect_ratio パラメータを使用して、必要なモデルを指定できます。

Python

import time
from google import genai
from google.genai import types

client = genai.Client()

prompt = """A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video."""

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    config=types.GenerateVideosConfig(
      aspect_ratio="9:16",
    ),
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the generated video.
generated_video = operation.response.generated_videos[0]
client.files.download(file=generated_video.video)
generated_video.video.save("pizza_making.mp4")
print("Generated video saved to pizza_making.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = `A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video.`;

let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
    config: {
      aspectRatio: "9:16",
    },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the generated video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "pizza_making.mp4",
});
console.log(`Generated video saved to pizza_making.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    prompt := `A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video.`

  videoConfig := &genai.GenerateVideosConfig{
      AspectRatio: "9:16",
  }

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
        nil,
        videoConfig,
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
    log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the generated video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "pizza_making.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "prompt": "A montage of pizza making: a chef tossing and flattening the floury dough, ladling rich red tomato sauce in a spiral, sprinkling mozzarella cheese and pepperoni, and a final shot of the bubbling golden-brown pizza, upbeat electronic music with a rhythmical beat is playing, high energy professional video."
      }
    ],
    "parameters": {
      "aspectRatio": "9:16"
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o pizza_making.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 5 seconds before checking again.
  sleep 10
done

解像度を制御する

Veo 3.1 では、720p、1080p、4K の動画を直接生成することもできます。

解像度が高いほど、レイテンシが高くなります。4K 動画は価格も高くなります(料金を参照)。

動画拡張機能も 720p の動画に限定されます。

Python

import time
from google import genai
from google.genai import types

client = genai.Client()

prompt = """A stunning drone view of the Grand Canyon during a flamboyant sunset that highlights the canyon's colors. The drone slowly flies towards the sun then accelerates, dives and flies inside the canyon."""

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    config=types.GenerateVideosConfig(
      resolution="4k",
    ),
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the generated video.
generated_video = operation.response.generated_videos[0]
client.files.download(file=generated_video.video)
generated_video.video.save("4k_grand_canyon.mp4")
print("Generated video saved to 4k_grand_canyon.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = `A stunning drone view of the Grand Canyon during a flamboyant sunset that highlights the canyon's colors. The drone slowly flies towards the sun then accelerates, dives and flies inside the canyon.`;

let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
    config: {
      resolution: "4k",
    },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the generated video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "4k_grand_canyon.mp4",
});
console.log(`Generated video saved to 4k_grand_canyon.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    prompt := `A stunning drone view of the Grand Canyon during a flamboyant sunset that highlights the canyon's colors. The drone slowly flies towards the sun then accelerates, dives and flies inside the canyon.`

  videoConfig := &genai.GenerateVideosConfig{
      Resolution: "4k",
  }

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
        nil,
        videoConfig,
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
    log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the generated video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "4k_grand_canyon.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "prompt": "A stunning drone view of the Grand Canyon during a flamboyant sunset that highlights the canyon'\''s colors. The drone slowly flies towards the sun then accelerates, dives and flies inside the canyon."
      }
    ],
    "parameters": {
      "resolution": "4k"
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o 4k_grand_canyon.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 5 seconds before checking again.
  sleep 10
done

画像から動画を生成する

次のコードは、Gemini 2.5 Flash Image(別名 Nano Banana)を使用して画像を生成し、その画像を Veo 3.1 で動画を生成するための開始フレームとして使用する方法を示しています。

Python

import time
from google import genai

client = genai.Client()

prompt = "Panning wide shot of a calico kitten sleeping in the sunshine"

# Step 1: Generate an image with Nano Banana.
image = client.models.generate_content(
    model="gemini-2.5-flash-image",
    contents=prompt,
    config={"response_modalities":['IMAGE']}
)

# Step 2: Generate video with Veo 3.1 using the image.
operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    image=image.parts[0].as_image(),
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the video.
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3_with_image_input.mp4")
print("Generated video saved to veo3_with_image_input.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = "Panning wide shot of a calico kitten sleeping in the sunshine";

// Step 1: Generate an image with Nano Banana.
const imageResponse = await ai.models.generateContent({
  model: "gemini-2.5-flash-image",
  prompt: prompt,
});

// Step 2: Generate video with Veo 3.1 using the image.
let operation = await ai.models.generateVideos({
  model: "veo-3.1-generate-preview",
  prompt: prompt,
  image: {
    imageBytes: imageResponse.generatedImages[0].image.imageBytes,
    mimeType: "image/png",
  },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
  console.log("Waiting for video generation to complete...")
  await new Promise((resolve) => setTimeout(resolve, 10000));
  operation = await ai.operations.getVideosOperation({
    operation: operation,
  });
}

// Download the video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "veo3_with_image_input.mp4",
});
console.log(`Generated video saved to veo3_with_image_input.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    prompt := "Panning wide shot of a calico kitten sleeping in the sunshine"

    // Step 1: Generate an image with Nano Banana.
    imageResponse, err := client.Models.GenerateContent(
        ctx,
        "gemini-2.5-flash-image",
        prompt,
        nil, // GenerateImagesConfig
    )
    if err != nil {
        log.Fatal(err)
    }

    // Step 2: Generate video with Veo 3.1 using the image.
    operation, err := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
        imageResponse.GeneratedImages[0].Image,
        nil, // GenerateVideosConfig
    )
    if err != nil {
        log.Fatal(err)
    }

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "veo3_with_image_input.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

Java

import com.google.genai.Client;
import com.google.genai.types.GenerateVideosOperation;
import com.google.genai.types.Image;
import com.google.genai.types.Video;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

class GenerateVideoFromImage {
  public static void main(String[] args) throws Exception {
    Client client = new Client();

    String prompt = "Panning wide shot of a calico kitten sleeping in the sunshine";

    // Step 1: Generate an image with Nano Banana:
    // ...
    // We assume 'image' contains the generated image from step 1,
    // or is loaded from a file:
    Image image = Image.fromFile("path/to/your/image.png");

    // Step 2: Generate video with Veo 3.1 using the image.
    GenerateVideosOperation operation =
        client.models.generateVideos("veo-3.1-generate-preview", prompt, image, null);

    // Poll the operation status until the video is ready.
    while (!operation.done().isPresent() || !operation.done().get()) {
      System.out.println("Waiting for video generation to complete...");
      Thread.sleep(10000);
      operation = client.operations.getVideosOperation(operation, null);
    }

    // Download the video.
    Video video = operation.response().get().generatedVideos().get().get(0).video().get();
    Path path = Paths.get("veo3_with_image_input.mp4");
    client.files.download(video, path.toString(), null);
    if (video.videoBytes().isPresent()) {
      Files.write(path, video.videoBytes().get());
      System.out.println("Generated video saved to veo3_with_image_input.mp4");
    }
  }
}

参照画像を使用する

Veo 3.1 では、生成された動画のコンテンツをガイドする参照画像を最大 3 枚まで使用できるようになりました。人物、キャラクター、商品の画像を提供して、出力動画で被写体の外観を保持します。

たとえば、Nano Banana で生成された 3 つの画像をリファレンスとして使用し、適切なプロンプトを使用すると、次の動画が作成されます。

`dress_image` `woman_image` `glasses_image`
ピンクとフューシャの羽が何層にも重なった、ハイファッションなフラミンゴ ドレス 黒髪で温かみのある茶色の瞳の美しい女性 ピンクのハート型のサングラス

Python

import time
from google import genai

client = genai.Client()

prompt = "The video opens with a medium, eye-level shot of a beautiful woman with dark hair and warm brown eyes. She wears a magnificent, high-fashion flamingo dress with layers of pink and fuchsia feathers, complemented by whimsical pink, heart-shaped sunglasses. She walks with serene confidence through the crystal-clear, shallow turquoise water of a sun-drenched lagoon. The camera slowly pulls back to a medium-wide shot, revealing the breathtaking scene as the dress's long train glides and floats gracefully on the water's surface behind her. The cinematic, dreamlike atmosphere is enhanced by the vibrant colors of the dress against the serene, minimalist landscape, capturing a moment of pure elegance and high-fashion fantasy."

dress_reference = types.VideoGenerationReferenceImage(
  image=dress_image, # Generated separately with Nano Banana
  reference_type="asset"
)

sunglasses_reference = types.VideoGenerationReferenceImage(
  image=glasses_image, # Generated separately with Nano Banana
  reference_type="asset"
)

woman_reference = types.VideoGenerationReferenceImage(
  image=woman_image, # Generated separately with Nano Banana
  reference_type="asset"
)

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    config=types.GenerateVideosConfig(
      reference_images=[dress_reference, glasses_reference, woman_reference],
    ),
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the video.
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3.1_with_reference_images.mp4")
print("Generated video saved to veo3.1_with_reference_images.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = "The video opens with a medium, eye-level shot of a beautiful woman with dark hair and warm brown eyes. She wears a magnificent, high-fashion flamingo dress with layers of pink and fuchsia feathers, complemented by whimsical pink, heart-shaped sunglasses. She walks with serene confidence through the crystal-clear, shallow turquoise water of a sun-drenched lagoon. The camera slowly pulls back to a medium-wide shot, revealing the breathtaking scene as the dress's long train glides and floats gracefully on the water's surface behind her. The cinematic, dreamlike atmosphere is enhanced by the vibrant colors of the dress against the serene, minimalist landscape, capturing a moment of pure elegance and high-fashion fantasy.";

// dressImage, glassesImage, womanImage generated separately with Nano Banana
// and available as objects like { imageBytes: "...", mimeType: "image/png" }
const dressReference = {
  image: dressImage,
  referenceType: "asset",
};
const sunglassesReference = {
  image: glassesImage,
  referenceType: "asset",
};
const womanReference = {
  image: womanImage,
  referenceType: "asset",
};

let operation = await ai.models.generateVideos({
  model: "veo-3.1-generate-preview",
  prompt: prompt,
  config: {
    referenceImages: [
      dressReference,
      sunglassesReference,
      womanReference,
    ],
  },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
  console.log("Waiting for video generation to complete...");
  await new Promise((resolve) => setTimeout(resolve, 10000));
  operation = await ai.operations.getVideosOperation({
    operation: operation,
  });
}

// Download the video.
ai.files.download({
  file: operation.response.generatedVideos[0].video,
  downloadPath: "veo3.1_with_reference_images.mp4",
});
console.log(`Generated video saved to veo3.1_with_reference_images.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

  prompt := `The video opens with a medium, eye-level shot of a beautiful woman with dark hair and warm brown eyes. She wears a magnificent, high-fashion flamingo dress with layers of pink and fuchsia feathers, complemented by whimsical pink, heart-shaped sunglasses. She walks with serene confidence through the crystal-clear, shallow turquoise water of a sun-drenched lagoon. The camera slowly pulls back to a medium-wide shot, revealing the breathtaking scene as the dress's long train glides and floats gracefully on the water's surface behind her. The cinematic, dreamlike atmosphere is enhanced by the vibrant colors of the dress against the serene, minimalist landscape, capturing a moment of pure elegance and high-fashion fantasy.`

  // dressImage, glassesImage, womanImage generated separately with Nano Banana
  // and available as *genai.Image objects.
  var dressImage, glassesImage, womanImage *genai.Image

  dressReference := &genai.VideoGenerationReferenceImage{
    Image: dressImage,
    ReferenceType: "asset",
  }
  sunglassesReference := &genai.VideoGenerationReferenceImage{
    Image: glassesImage,
    ReferenceType: "asset",
  }
  womanReference := &genai.VideoGenerationReferenceImage{
    Image: womanImage,
    ReferenceType: "asset",
  }

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
    nil, // image
        &genai.GenerateVideosConfig{
      ReferenceImages: []*genai.VideoGenerationReferenceImage{
        dressReference,
        sunglassesReference,
        womanReference,
      },
    },
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "veo3.1_with_reference_images.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# It assumes dress_image_base64, glasses_image_base64, and woman_image_base64
# contain base64-encoded image data.

# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
      "prompt": "The video opens with a medium, eye-level shot of a beautiful woman with dark hair and warm brown eyes. She wears a magnificent, high-fashion flamingo dress with layers of pink and fuchsia feathers, complemented by whimsical pink, heart-shaped sunglasses. She walks with serene confidence through the crystal-clear, shallow turquoise water of a sun-drenched lagoon. The camera slowly pulls back to a medium-wide shot, revealing the breathtaking scene as the dress'\''s long train glides and floats gracefully on the water'\''s surface behind her. The cinematic, dreamlike atmosphere is enhanced by the vibrant colors of the dress against the serene, minimalist landscape, capturing a moment of pure elegance and high-fashion fantasy."
    }],
    "parameters": {
      "referenceImages": [
        {
          "image": {"inlineData": {"mimeType": "image/png", "data": "'"$dress_image_base64"'"}},
          "referenceType": "asset"
        },
        {
          "image": {"inlineData": {"mimeType": "image/png", "data": "'"$glasses_image_base64"'"}},
          "referenceType": "asset"
        },
        {
          "image": {"inlineData": {"mimeType": "image/png", "data": "'"$woman_image_base64"'"}},
          "referenceType": "asset"
        }
      ]
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o veo3.1_with_reference_images.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 10 seconds before checking again.
  sleep 10
done

最初と最後のフレームを使用する

Veo 3.1 では、補間を使用するか、動画の最初と最後のフレームを指定して動画を作成できます。動画生成用の効果的なテキスト プロンプトの作成については、Veo プロンプト ガイドをご覧ください。

Python

import time
from google import genai

client = genai.Client()

prompt = "A cinematic, haunting video. A ghostly woman with long white hair and a flowing dress swings gently on a rope swing beneath a massive, gnarled tree in a foggy, moonlit clearing. The fog thickens and swirls around her, and she slowly fades away, vanishing completely. The empty swing is left swaying rhythmically on its own in the eerie silence."

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
    image=first_image, # The starting frame is passed as a primary input
    config=types.GenerateVideosConfig(
      last_frame=last_image # The ending frame is passed as a generation constraint in the config
    ),
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the video.
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3.1_with_interpolation.mp4")
print("Generated video saved to veo3.1_with_interpolation.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = "A cinematic, haunting video. A ghostly woman with long white hair and a flowing dress swings gently on a rope swing beneath a massive, gnarled tree in a foggy, moonlit clearing. The fog thickens and swirls around her, and she slowly fades away, vanishing completely. The empty swing is left swaying rhythmically on its own in the eerie silence.";

// firstImage and lastImage generated separately with Nano Banana
// and available as objects like { imageBytes: "...", mimeType: "image/png" }
let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
    image: firstImage, // The starting frame is passed as a primary input
    config: {
      lastFrame: lastImage, // The ending frame is passed as a generation constraint in the config
    },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "veo3.1_with_interpolation.mp4",
});
console.log(`Generated video saved to veo3.1_with_interpolation.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

  prompt := `A cinematic, haunting video. A ghostly woman with long white hair and a flowing dress swings gently on a rope swing beneath a massive, gnarled tree in a foggy, moonlit clearing. The fog thickens and swirls around her, and she slowly fades away, vanishing completely. The empty swing is left swaying rhythmically on its own in the eerie silence.`

  // firstImage and lastImage generated separately with Nano Banana
  // and available as *genai.Image objects.
  var firstImage, lastImage *genai.Image

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
    firstImage, // The starting frame is passed as a primary input
        &genai.GenerateVideosConfig{
      LastFrame: lastImage, // The ending frame is passed as a generation constraint in the config
    },
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "veo3.1_with_interpolation.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# It assumes first_image_base64 and last_image_base64
# contain base64-encoded image data.

# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
# The starting frame is passed as a primary input
# The ending frame is passed as a generation constraint in the config
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
      "prompt": "A cinematic, haunting video. A ghostly woman with long white hair and a flowing dress swings gently on a rope swing beneath a massive, gnarled tree in a foggy, moonlit clearing. The fog thickens and swirls around her, and she slowly fades away, vanishing completely. The empty swing is left swaying rhythmically on its own in the eerie silence.",
      "image": {"inlineData": {"mimeType": "image/png", "data": "'"$first_image_base64"'"}}
    }],
    "parameters": {
      "lastFrame": {"inlineData": {"mimeType": "image/png", "data": "'"$last_image_base64"'"}}
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o veo3.1_with_interpolation.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 10 seconds before checking again.
  sleep 10
done
`first_image` `last_image` veo3.1_with_interpolation.mp4
長い白髪と流れるようなドレスを着た幽霊のような女性が、ロープのブランコに優しく揺られている ブランコから消える幽霊の女性 霧の中でブランコから消える不気味な女性の、映画のような不気味な動画

Veo 動画を拡張する

Veo 3.1 を使用すると、以前に Veo で生成した動画を 7 秒間、最大 20 回まで延長できます。

入力動画の制限:

  • Veo で生成された動画の長さは 141 秒まで。
  • Gemini API は、Veo で生成された動画の動画拡張機能のみをサポートしています。
  • 動画は operation.response.generated_videos[0].video などの以前の世代のものである必要があります。
  • 動画は 2 日間保存されますが、延長のために動画が参照されると、2 日間の保存タイマーがリセットされます。延長できるのは、過去 2 日以内に生成または参照された動画のみです。
  • 入力動画には、一定の長さ、アスペクト比、サイズが求められます。
    • アスペクト比: 9:16 または 16:9
    • 解像度: 720p
    • 動画の長さ: 141 秒以内

この拡張機能の出力は、ユーザー入力動画と生成された延長動画を組み合わせた 1 本の動画で、最大 148 秒の動画になります。

この例では、Veo で生成された動画(元のプロンプトとともに表示)を取得し、video パラメータと新しいプロンプトを使用して拡張しています。

プロンプト 出力: butterfly_video
折り紙の蝶が羽ばたき、フランス窓から庭に飛び立つ。 折り紙の蝶が羽ばたき、フレンチドアから庭に飛び出します。

Python

import time
from google import genai

client = genai.Client()

prompt = "Track the butterfly into the garden as it lands on an orange origami flower. A fluffy white puppy runs up and gently pats the flower."

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    video=operation.response.generated_videos[0].video, # This must be a video from a previous generation
    prompt=prompt,
    config=types.GenerateVideosConfig(
        number_of_videos=1,
        resolution="720p"
    ),
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the video.
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3.1_extension.mp4")
print("Generated video saved to veo3.1_extension.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = "Track the butterfly into the garden as it lands on an orange origami flower. A fluffy white puppy runs up and gently pats the flower.";

// butterflyVideo must be a video from a previous generation
// available as an object like { videoBytes: "...", mimeType: "video/mp4" }
let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    video: butterflyVideo,
    prompt: prompt,
    config: {
        numberOfVideos: 1,
        resolution: "720p",
    },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "veo3.1_extension.mp4",
});
console.log(`Generated video saved to veo3.1_extension.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

  prompt := `Track the butterfly into the garden as it lands on an orange origami flower. A fluffy white puppy runs up and gently pats the flower.`

  // butterflyVideo must be a video from a previous generation
  // available as a *genai.Video object.
  var butterflyVideo *genai.Video

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        prompt,
    nil, // image
    butterflyVideo,
        &genai.GenerateVideosConfig{
      NumberOfVideos: 1,
      Resolution: "720p",
    },
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "veo3.1_extension.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# It assumes butterfly_video_base64 contains base64-encoded
# video data from a previous generation.

# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
      "prompt": "Track the butterfly into the garden as it lands on an orange origami flower. A fluffy white puppy runs up and gently pats the flower.",
      "video": {"inlineData": {"mimeType": "video/mp4", "data": "'"$butterfly_video_base64"'"}}
    }],
    "parameters": {
      "numberOfVideos": 1,
      "resolution": "720p"
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o veo3.1_extension.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 10 seconds before checking again.
  sleep 10
done

動画生成用の効果的なテキスト プロンプトの作成については、Veo プロンプト ガイドをご覧ください。

非同期オペレーションの処理

動画の生成は、コンピューティング集約型のタスクです。API にリクエストを送信すると、長時間実行ジョブが開始され、すぐに operation オブジェクトが返されます。次に、done ステータスが true になるまでポーリングする必要があります。

このプロセスの中心は、ジョブのステータスを定期的にチェックするポーリング ループです。

Python

import time
from google import genai
from google.genai import types

client = genai.Client()

# After starting the job, you get an operation object.
operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt="A cinematic shot of a majestic lion in the savannah.",
)

# Alternatively, you can use operation.name to get the operation.
operation = types.GenerateVideosOperation(name=operation.name)

# This loop checks the job status every 10 seconds.
while not operation.done:
    time.sleep(10)
    # Refresh the operation object to get the latest status.
    operation = client.operations.get(operation)

# Once done, the result is in operation.response.
# ... process and download your video ...

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

// After starting the job, you get an operation object.
let operation = await ai.models.generateVideos({
  model: "veo-3.1-generate-preview",
  prompt: "A cinematic shot of a majestic lion in the savannah.",
});

// Alternatively, you can use operation.name to get the operation.
// operation = types.GenerateVideosOperation(name=operation.name)

// This loop checks the job status every 10 seconds.
while (!operation.done) {
    await new Promise((resolve) => setTimeout(resolve, 1000));
    // Refresh the operation object to get the latest status.
    operation = await ai.operations.getVideosOperation({ operation });
}

// Once done, the result is in operation.response.
// ... process and download your video ...

Go

package main

import (
    "context"
    "log"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    // After starting the job, you get an operation object.
    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        "A cinematic shot of a majestic lion in the savannah.",
        nil,
        nil,
    )

    // This loop checks the job status every 10 seconds.
    for !operation.Done {
        time.Sleep(10 * time.Second)
        // Refresh the operation object to get the latest status.
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Once done, the result is in operation.Response.
    // ... process and download your video ...
}

Java

import com.google.genai.Client;
import com.google.genai.types.GenerateVideosOperation;
import com.google.genai.types.Video;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

class HandleAsync {
  public static void main(String[] args) throws Exception {
    Client client = new Client();

    // After starting the job, you get an operation object.
    GenerateVideosOperation operation =
        client.models.generateVideos(
            "veo-3.1-generate-preview",
            "A cinematic shot of a majestic lion in the savannah.",
            null,
            null);

    // This loop checks the job status every 10 seconds.
    while (!operation.done().isPresent() || !operation.done().get()) {
      Thread.sleep(10000);
      // Refresh the operation object to get the latest status.
      operation = client.operations.getVideosOperation(operation, null);
    }

    // Once done, the result is in operation.response.
    // Download the generated video.
    Video video = operation.response().get().generatedVideos().get().get(0).video().get();
    Path path = Paths.get("async_example.mp4");
    client.files.download(video, path.toString(), null);
    if (video.videoBytes().isPresent()) {
      Files.write(path, video.videoBytes().get());
      System.out.println("Generated video saved to async_example.mp4");
    }
  }
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "prompt": "A cinematic shot of a majestic lion in the savannah."
      }
    ]
  }' | jq -r .name)

# This loop checks the job status every 10 seconds.
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Once done, the result is in status_response.
    # ... process and download your video ...
    echo "Video generation complete."
    break
  fi
  # Wait for 10 seconds before checking again.
  echo "Waiting for video generation to complete..."
  sleep 10
done

Veo API のパラメータと仕様

API リクエストで設定して動画生成プロセスを制御できるパラメータは次のとおりです。

パラメータ 説明 Veo 3.1 と Veo 3.1 Fast Veo 3 と Veo 3 Fast Veo 2
prompt 動画のテキストによる説明。音声キューをサポートしています。 string string string
negativePrompt 動画に含めてはならない内容を説明するテキスト。 string string string
image アニメーション化する最初の画像。 Image オブジェクト Image オブジェクト Image オブジェクト
lastFrame 補間動画の最終画像。image パラメータと組み合わせて使用する必要があります。 Image オブジェクト Image オブジェクト Image オブジェクト
referenceImages スタイルとコンテンツの参照として使用する画像を 3 枚まで。 VideoGenerationReferenceImage オブジェクト(Veo 3.1 のみ) なし なし
video 動画広告で使用する動画。 前の世代の Video オブジェクト なし なし
aspectRatio 動画のアスペクト比。 "16:9"(デフォルト)、
"9:16"

"16:9"(デフォルト)、
"9:16"
"16:9"(デフォルト)、
"9:16"
resolution 動画のアスペクト比。 "720p"(デフォルト)、
"1080p"(8 秒の長さのみをサポート)、
"4k"(8 秒の長さのみをサポート)

"720p"(拡張機能のみ)
"720p"(デフォルト)、
"1080p"(8 秒の長さのみをサポート)、
"4k"(8 秒の長さのみをサポート)

"720p"(拡張機能のみ)
サポート対象外
durationSeconds 生成された動画の長さ。 "4""6""8"

拡張機能、参照画像、または 1080p と 4k の解像度を使用する場合は「8」である必要があります
"4""6""8"

拡張機能、参照画像、または 1080p と 4k の解像度を使用する場合は「8」である必要があります
"5""6""8"
personGeneration 人物の生成を制御します。
(リージョン制限については、制限事項をご覧ください)
テキストから動画を作成、拡張機能:
"allow_all" のみ
画像から動画を作成、補間、参照画像:
"allow_adult" のみ
テキストから動画を作成:
"allow_all" のみ
画像から動画を作成:
"allow_adult" のみ
テキストから動画を作成:
"allow_all""allow_adult""dont_allow"
画像から動画を作成:
"allow_adult""dont_allow"

seed パラメータは Veo 3 モデルでも使用できます。決定論は保証されませんが、わずかに改善されます。

リクエストでパラメータを設定することで、動画生成をカスタマイズできます。たとえば、negativePrompt を指定してモデルをガイドできます。

Python

import time
from google import genai
from google.genai import types

client = genai.Client()

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt="A cinematic shot of a majestic lion in the savannah.",
    config=types.GenerateVideosConfig(negative_prompt="cartoon, drawing, low quality"),
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the generated video.
generated_video = operation.response.generated_videos[0]
client.files.download(file=generated_video.video)
generated_video.video.save("parameters_example.mp4")
print("Generated video saved to parameters_example.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

let operation = await ai.models.generateVideos({
  model: "veo-3.1-generate-preview",
  prompt: "A cinematic shot of a majestic lion in the savannah.",
  config: {
    aspectRatio: "16:9",
    negativePrompt: "cartoon, drawing, low quality"
  },
});

// Poll the operation status until the video is ready.
while (!operation.done) {
  console.log("Waiting for video generation to complete...")
  await new Promise((resolve) => setTimeout(resolve, 10000));
  operation = await ai.operations.getVideosOperation({
    operation: operation,
  });
}

// Download the generated video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "parameters_example.mp4",
});
console.log(`Generated video saved to parameters_example.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    videoConfig := &genai.GenerateVideosConfig{
        AspectRatio: "16:9",
        NegativePrompt: "cartoon, drawing, low quality",
    }

    operation, _ := client.Models.GenerateVideos(
        ctx,
        "veo-3.1-generate-preview",
        "A cinematic shot of a majestic lion in the savannah.",
        nil,
        videoConfig,
    )

    // Poll the operation status until the video is ready.
    for !operation.Done {
        log.Println("Waiting for video generation to complete...")
        time.Sleep(10 * time.Second)
        operation, _ = client.Operations.GetVideosOperation(ctx, operation, nil)
    }

    // Download the generated video.
    video := operation.Response.GeneratedVideos[0]
    client.Files.Download(ctx, video.Video, nil)
    fname := "parameters_example.mp4"
    _ = os.WriteFile(fname, video.Video.VideoBytes, 0644)
    log.Printf("Generated video saved to %s\n", fname)
}

REST

# Note: This script uses jq to parse the JSON response.
# GEMINI API Base URL
BASE_URL="https://generativelanguage.googleapis.com/v1beta"

# Send request to generate video and capture the operation name into a variable.
operation_name=$(curl -s "${BASE_URL}/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "instances": [{
        "prompt": "A cinematic shot of a majestic lion in the savannah."
      }
    ],
    "parameters": {
      "aspectRatio": "16:9",
      "negativePrompt": "cartoon, drawing, low quality"
    }
  }' | jq -r .name)

# Poll the operation status until the video is ready
while true; do
  # Get the full JSON status and store it in a variable.
  status_response=$(curl -s -H "x-goog-api-key: $GEMINI_API_KEY" "${BASE_URL}/${operation_name}")

  # Check the "done" field from the JSON stored in the variable.
  is_done=$(echo "${status_response}" | jq .done)

  if [ "${is_done}" = "true" ]; then
    # Extract the download URI from the final response.
    video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
    echo "Downloading video from: ${video_uri}"

    # Download the video using the URI and API key and follow redirects.
    curl -L -o parameters_example.mp4 -H "x-goog-api-key: $GEMINI_API_KEY" "${video_uri}"
    break
  fi
  # Wait for 5 seconds before checking again.
  sleep 10
done

Veo プロンプト ガイド

このセクションでは、Veo を使用して作成できる動画の例を紹介し、プロンプトを変更して異なる結果を生成する方法について説明します。

安全フィルタ

Veo は、Gemini 全体で安全フィルタを適用し、生成された動画やアップロードされた写真に不適切なコンテンツが含まれていないことを確認します。Google の利用規約とガイドラインに違反するプロンプトはブロックされます。

プロンプト作成の基本

適切なプロンプトは、説明的で明確なものです。Veo を最大限に活用するには、まず主なアイデアを特定し、キーワードと修飾子を追加してアイデアを洗練させ、動画固有の用語をプロンプトに組み込みます。

プロンプトには次の要素を含める必要があります。

  • 主題: 動画に含めたい物体、人物、動物、風景(街並み自然乗り物子犬など)。
  • アクション: 被写体の動き(歩く走る首を回すなど)。
  • スタイル: SFホラー映画フィルム ノワール漫画などのアニメーション スタイルなど、特定の映画スタイルのキーワードを使用してクリエイティブの方向性を指定します。
  • カメラの位置と動き: [省略可] 空撮目の高さ俯瞰撮影ドリー撮影ローアングル撮影などの用語を使用して、カメラの位置と動きを制御します。
  • 構図: [省略可] ワイドショットクローズアップシングルショットツーショットなど、ショットのフレーム。
  • フォーカスとレンズ効果: [省略可] 浅いフォーカス深いフォーカスソフト フォーカスマクロレンズ広角レンズなどの用語を使用して、特定の視覚効果を実現します。
  • アンビアンス: [省略可] 色や光によるシーンへの影響(青い色調暖かい色調など)。

プロンプトの作成に関するその他のヒント

  • わかりやすい表現を使用する: 形容詞や副詞を使用して、Veo の明確な画像を描きます。
  • 顔の細部を補正する: プロンプトで「ポートレート」という単語を使用するなど、写真の焦点として顔の細部を指定します。

より包括的なプロンプト戦略については、プロンプト設計の概要をご覧ください。

音声のプロンプト

Veo 3 では、効果音、環境音、会話のキューを指定できます。モデルはこれらのキューのニュアンスを捉え、同期されたサウンドトラックを生成します。

  • 会話: 具体的な会話には引用符を使用します。(例: 「これが鍵に違いない」と彼はつぶやいた。)
  • 効果音(SFX): 音を明確に説明します。(例: タイヤの大きなスキール音、エンジンの轟音)。
  • 周囲の音: 環境のサウンドスケープを説明します。(例: 背景でかすかな不気味なハミングが響く。)

これらの動画は、Veo 3 の音声生成に詳細レベルを上げてプロンプトを入力する様子を示しています。

プロンプト 生成された出力
詳細(セリフとアンビエンス)
霧のかかった太平洋岸北西部の森のワイドショット。疲れた 2 人のハイカー(男性と女性)がシダをかき分けて進んでいると、男性が突然立ち止まり、木を見つめる。クローズアップ: 木の皮に深く新しい爪痕が刻まれています。男:(狩猟ナイフに手を当てて)「あれは普通のクマじゃない。」女性: (恐怖で声が震え、森を見回しながら)「じゃあ、何なの?」ざらざらした樹皮、折れる小枝、湿った地面を踏む足音。一羽の鳥がさえずる。
森の中でクマの痕跡を見つけた 2 人の人物。
Less detail (Dialogue)
切り絵アニメーション。新しい司書: 「禁書はどこに保管されていますか?」以前のキュレーター: 「いいえ。彼らは私たちを維持します。」
禁書について話し合うアニメーションの司書

以下のプロンプトを試して、音声を聞いてみましょう。 Veo 3 を試す

参照画像を使用したプロンプト

Veo の画像から動画への変換機能を使用して、1 つ以上の画像を生成動画のガイドとして使用できます。Veo は入力画像を最初のフレームとして使用します。動画の最初のシーンとして思い描いているものに最も近い画像を選択して、日常の物をアニメ化し、線画や絵画に命を吹き込み、自然の風景に動きと音を追加します。

プロンプト 生成された出力
入力画像(Nano Banana で生成)
素朴な石造りの洗面台の中で、小さなミニチュアのサーファーが海の波に乗っている超現実的なマクロ写真。真鍮製の古い蛇口から水が流れ、永遠の波が生まれています。シュールで奇抜な、明るい自然光。
素朴な石造りの洗面台の中で、小さなサーファーが海の波に乗っている。
出力動画(Veo 3.1 で生成)
シュールで映画のようなマクロ動画。小さなサーファーが、石造りの洗面台の中で永遠に続く波に乗っている。ヴィンテージの真鍮製の蛇口から流れ出る水が、無限の波を生み出します。ミニチュアの人物がターコイズ ブルーの海を巧みに切り開く、陽光に照らされた奇抜なシーンをカメラがゆっくりとパンする。
浴室のシンクで波に乗る小さなサーファー。

Veo 3.1 では、画像や素材を参照して、生成された動画のコンテンツを指定できます。1 人の人物、キャラクター、商品の画像を 3 枚まで指定します。Veo は、出力動画で被写体の外観を保持します。

プロンプト 生成された出力
参照画像(Nano Banana で生成)
深海の暗い水の中に、歯をむき出しにして餌を光らせているアンコウが潜んでいる。
暗闇で光るアンコウ
参照画像(Nano Banana で生成)
ピンク色の子供用プリンセス コスチューム。杖とティアラ付き。シンプルな商品の背景。
ピンクのプリンセス衣装を着た子供
出力動画(Veo 3.1 で生成)
衣装を着た魚が泳ぎながら魔法の杖を振っている、おかしな漫画風の動画を作成します。
プリンセス コスチュームを着たアンコウ

Veo 3.1 を使用すると、動画の最初と最後のフレームを指定して動画を生成することもできます。

プロンプト 生成された出力
1 枚目の画像(Nano Banana で生成)
フランスのリビエラ海岸で赤いオープンカーのレーシングカーを運転する茶色の猫の高品質なリアルな正面画像。
赤いオープンカーのレーシングカーを運転する茶色の猫
最後の画像(Nano Banana で生成)
車が崖から飛び出す様子を表示します。
赤いオープンカーを運転する茶色の猫が崖から落ちる
出力動画(Veo 3.1 で生成)
省略可
猫が崖から飛び降りて飛び立つ

この機能を使用すると、開始フレームと終了フレームを定義して、ショットの構図を正確に制御できます。画像をアップロードするか、以前の動画生成のフレームを使用して、シーンが思い描いたとおりに開始し、終了するようにします。

拡張機能のプロンプト

Veo 3.1 で Veo 生成の動画を延長するには、動画を入力として使用し、オプションでテキスト プロンプトも使用します。拡張では、動画の最後の 1 秒または 24 フレームを完了し、アクションを続行します。

動画の最後の 1 秒に音声が含まれていない場合、音声を効果的に延長することはできません。

プロンプト 生成された出力
入力動画(Veo 3.1 で生成)
パラグライダーが山頂から飛び立ち、眼下に広がる花畑の谷を見下ろしながら山を滑空し始める。
山頂から飛び立つパラグライダー
出力動画(Veo 3.1 で生成)
パラグライダーがゆっくりと降下する動画を延長します。
山頂からパラグライダーが飛び立ち、ゆっくりと降下していく

プロンプトと出力の例

このセクションでは、いくつかのプロンプトを紹介し、説明的な詳細情報が各動画の結果をどのように向上させるかについて説明します。

アイシクル

この動画では、プロンプト作成の基本の要素をプロンプトで使用する方法について説明します。

プロンプト 生成された出力
凍った岩壁(コンテキスト)に垂れ下がる氷柱(被写体)が溶けている様子を、青みがかったトーン(雰囲気)でクローズアップ(構図)した写真。水滴(アクション)のクローズアップのディテールを維持しながら、ズームイン(カメラの動き)している。 青い背景に垂れるつらら。

電話中の男性

これらの動画では、より具体的な詳細情報をプロンプトに追加して、Veo が出力を好みに合わせて調整する方法を示しています。

プロンプト 生成された出力
詳細を減らす
カメラがドリーして、緑色のトレンチコートを着た絶望的な表情の男のクローズアップを映し出す。緑色のネオンライトを背景に、ダイヤル式の壁掛け電話で話している。映画のシーンのようです。
電話で話している男性。
詳細
緑色のネオンサインの不気味な光に照らされた、ざらざらしたレンガの壁に取り付けられたダイヤル式電話を回す、緑色のトレンチコートを着た絶望的な男を追うクローズアップの映画のようなショット。カメラがドリーインし、電話をかけようと苦労する彼の顎の緊張と顔に刻まれた絶望が映し出される。被写界深度が浅いため、眉をひそめた男性と黒いダイヤル式電話に焦点が当てられ、背景はネオンカラーと不明瞭な影の海にぼかされ、緊急性と孤立感が演出されている。
電話で話す男性

ユキヒョウ

プロンプト 生成された出力
シンプルなプロンプト:
雪豹のような毛皮を持つかわいい生き物が冬の森を歩いている。3D アニメ風のレンダリング。
ユキヒョウがぐったりしている。
詳細なプロンプト:
楽しいアニメーション スタイルの短い 3D アニメーション シーンを作成します。雪ヒョウのような毛皮、大きな表情豊かな目、丸みを帯びたフレンドリーな姿をしたかわいい生き物が、風変わりな冬の森を嬉しそうに跳ね回っている。丸みを帯びた雪に覆われた木々、優しく舞い落ちる雪、枝の間から差し込む暖かい太陽光を表現してください。生き物の弾むような動きと満面の笑みで、純粋な喜びを表現してください。明るく陽気な色と遊び心のあるアニメーションで、アップビートで心温まるトーンを目指します。
ユキヒョウがより速く走っています。

ライティング要素別の例

これらの例は、各基本要素でプロンプトを絞り込む方法を示しています。

件名とコンテキスト

メインの被写体(主題)と背景または環境(コンテキスト)を指定します。

プロンプト 生成された出力
白いコンクリート製のアパートメント ビルを建築レンダリングした画像。流れるような有機的な形状で、緑豊かな植物や未来的な要素とシームレスに調和している プレースホルダ。
宇宙空間を漂う衛星。背景には月と星がいくつか見える。 大気圏を漂う人工衛星。

アクション

被写体が何をしているかを指定します(歩く、走る、頭を回すなど)。

プロンプト 生成された出力
夕暮れ時にビーチを歩き、満足そうな表情で水平線を眺める女性のワイドショット。 夕日は本当に美しいです。

スタイル

キーワードを追加して、特定の美学(シュール、ビンテージ、未来、フィルム ノワールなど)に沿って生成されるようにします。

プロンプト 生成された出力
フィルム ノワール風の、通りを歩く男女、ミステリー、映画のような、白黒。 フィルム ノワール スタイルは本当に美しいです。

カメラの動きと構図

カメラの動き(主観ショット、空撮、追跡ドローン ビュー)とショットの構図(広角、アップ、ローアングル)を指定します。

プロンプト 生成された出力
雨の中を走るクラシックカーの車内から撮影した POV ショット。カナダの夜、映画のような雰囲気。 夕日は本当に美しいです。
街が映り込んだ目を極端にクローズアップした画像。 夕日は本当に美しいです。

雰囲気

カラーパレットと照明はムードに影響します。「くすんだオレンジ色の暖色系」、「自然光」、「日の出」、「青色の寒色系」などのキーワードを試してみてください。

プロンプト 生成された出力
公園で愛らしいゴールデン レトリバーの子犬を抱いている少女のクローズアップ、日光。 女の子の腕に抱かれている子犬。
雨の中、バスに乗る悲しげな女性の映画のようなクローズアップ。クールな青いトーン、悲しい雰囲気。 バスに乗って悲しそうな女性。

ネガティブ プロンプト

ネガティブ プロンプトでは、動画に含めたくない要素を指定します。

  • ❌ 「なし」や「しない」などの手順を示す言葉は使用しないでください。(例: 「壁なし」)。
  • ✅ 含めたくないものをわかりやすく記述します。(例: 「壁、フレーム」)。
プロンプト 生成された出力
ネガティブ プロンプトなし:
強風で葉が激しく揺れる、大きな一本のオークの木を様式化した短いアニメーションを生成してください。[切り捨て]
言葉で説明した木。
ネガティブ プロンプトあり:
[同じプロンプト]

ネガティブ プロンプト: 都市の背景、人工建造物、暗い、嵐、脅威的な雰囲気。
否定的な言葉を使用せずに生成した木。

アスペクト比

Veo では、動画のアスペクト比を指定できます。

プロンプト 生成された出力
ワイドスクリーン(16:9)
1970 年代のパーム スプリングスで、赤いオープンカーを運転する男性を追跡するドローン視点の動画を作成します。暖かい日差し、長い影。
パーム スプリングスで赤いオープンカーを運転する男性(1970 年代風)。
縦向き(9:16)
緑豊かな熱帯雨林にある雄大なハワイの滝の滑らかな動きを強調した動画を作成します。リアルな水の流れ、細部まで表現された葉、自然な光に焦点を当て、静けさを表現します。流れ落ちる水、霧に包まれた雰囲気、密生した樹冠から差し込む斑状の太陽光を捉えてください。滑らかで映画のようなカメラワークで、滝とその周辺の様子を映し出します。平和で現実的なトーンを目指し、ハワイの熱帯雨林の静かな美しさを視聴者に伝える。
緑豊かな熱帯雨林にある雄大なハワイの滝。

制限事項

  • リクエスト レイテンシ: 最小: 11 秒、最大: 6 分(ピーク時)。
  • 地域別の制限事項: EU、英国、スイス、中東、北アフリカの地域では、personGeneration に使用できる値は次のとおりです。
    • Veo 3: allow_adult のみ。
    • Veo 2: dont_allowallow_adult。デフォルトは dont_allow です。
  • 動画の保持: 生成された動画は 2 日間サーバーに保存され、その後削除されます。ローカルコピーを保存するには、動画が生成されてから 2 日以内にダウンロードする必要があります。延長された動画は、新たに生成された動画として扱われます。
  • 透かし: Veo で作成された動画には、AI 生成コンテンツに透かしを入れて識別するための Google のツールである SynthID を使用して透かしが入れられます。動画は SynthID 検証プラットフォームを使用して検証できます。
  • 安全性: 生成された動画は、プライバシー、著作権、バイアスのリスクを軽減するのに役立つ安全フィルタと記憶チェック プロセスを通過します。
  • 音声エラー: Veo 3.1 では、音声の安全フィルターやその他の処理の問題により、動画の生成がブロックされることがあります。動画の生成がブロックされた場合は、料金は発生しません。

モデルの特徴

機能 説明 Veo 3.1 と Veo 3.1 Fast Veo 3 と Veo 3 Fast Veo 2
音声 動画とともに音声をネイティブに生成します。 動画とともに音声をネイティブに生成します。 ✔️ 常にオン ❌ サイレントのみ
入力モード 生成に使用される入力のタイプ。 テキストから動画を作成、画像から動画を作成、動画から動画を作成 テキストから動画を作成、画像から動画を作成 テキストから動画を作成、画像から動画を作成
解決策 動画の出力解像度。 720p、1080p(8 秒のみ)、4k(8 秒のみ)

動画広告拡張機能を使用している場合は 720p のみ。
720p と 1080p(16:9 のみ) 720p
フレームレート 動画の出力フレームレート。 24 fps 24 fps 24 fps
動画の再生時間 生成された動画の長さ。 8 秒、6 秒、4 秒

1080p または 4k の場合、または参照画像を使用している場合のみ 8 秒
8秒 5 ~ 8 秒
リクエストあたりの動画数 リクエストごとに生成される動画の数。 1 1 1 または 2
ステータスと詳細 モデルの提供状況と詳細。 プレビュー Stable Stable

モデル バージョン

Veo モデル固有の使用量の詳細については、料金レート制限のページをご覧ください。

Veo Fast バージョンでは、高品質を維持しながら、速度とビジネス ユースケースに合わせて最適化された音声付き動画を作成できます。広告をプログラムで生成するバックエンド サービス、クリエイティブ コンセプトの迅速な A/B テストを行うツール、ソーシャル メディア コンテンツをすばやく作成する必要があるアプリなどに最適です。

Veo 3.1 プレビュー版

プロパティ 説明
モデルコード

Gemini API

veo-3.1-generate-preview

でサポートされるデータ型

入力

テキスト、画像

出力

音声付きの動画

の上限

テキスト入力

1,024 個のトークン

出力動画

1

最終更新日 2026 年 1 月

Veo 3.1 Fast プレビュー

プロパティ 説明
モデルコード

Gemini API

veo-3.1-fast-generate-preview

でサポートされるデータ型

入力

テキスト、画像

出力

音声付きの動画

の上限

テキスト入力

1,024 個のトークン

出力動画

1

最終更新日 2025 年 9 月

Veo 2

プロパティ 説明
モデルコード

Gemini API

veo-2.0-generate-001

でサポートされるデータ型

入力

テキスト、画像

出力

動画

の上限

テキスト入力

なし

画像入力

ファイルサイズが 20 MB までの任意の解像度とアスペクト比の画像

出力動画

最大 2 個

最終更新日 2025 年 4 月

次のステップ