CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-google-genai--google-genai

Java idiomatic SDK for the Gemini Developer APIs and Vertex AI APIs

Overview
Eval results
Files

video-generation.mddocs/

Video Generation

Generate videos from text prompts or images using Veo models.

Core Imports

import com.google.genai.types.GenerateVideosOperation;
import com.google.genai.types.GenerateVideosConfig;
import com.google.genai.types.GenerateVideosSource;
import com.google.genai.types.GeneratedVideo;
import com.google.genai.types.Video;
import com.google.genai.types.Image;

Generate Videos

public GenerateVideosOperation generateVideos(
    String model,
    GenerateVideosSource source,
    GenerateVideosConfig config);

public GenerateVideosOperation generateVideos(
    String model,
    String prompt,
    Image image,
    Video video,
    GenerateVideosConfig config);

Text to Video

GenerateVideosConfig config = GenerateVideosConfig.builder()
    .numberOfVideos(1)
    .durationSeconds(5)
    .enhancePrompt(true)
    .build();

GenerateVideosOperation operation = client.models.generateVideos(
    "veo-2.0-generate-001",
    "A cat walking through a futuristic city",
    null,
    config
);

// Poll until complete
while (!operation.done().isPresent()) {
    Thread.sleep(10000);
    operation = client.operations.getVideosOperation(operation, null);
}

operation.response().ifPresent(response -> {
    response.generatedVideos().ifPresent(videos -> {
        for (GeneratedVideo video : videos) {
            System.out.println("Video: " + video.video().orElse(null));
        }
    });
});

Image to Video

Image image = Image.fromFile("path/to/image.jpg");

GenerateVideosConfig config = GenerateVideosConfig.builder()
    .numberOfVideos(1)
    .durationSeconds(5)
    .build();

GenerateVideosOperation operation = client.models.generateVideos(
    "veo-2.0-generate-001",
    "Animate this image with gentle camera movement",
    image,
    config
);

Download Generated Video

operation.response().ifPresent(response -> {
    response.generatedVideos().ifPresent(videos -> {
        GeneratedVideo video = videos.get(0);
        client.files.download(
            video,
            "path/to/output.mp4",
            null
        );
    });
});

Video Configuration

public final class GenerateVideosConfig {
  public static Builder builder();

  public Optional<Integer> numberOfVideos();
  public Optional<Integer> durationSeconds();
  public Optional<Boolean> enhancePrompt();
  public Optional<String> aspectRatio();
  public Optional<HttpOptions> httpOptions();
}

Install with Tessl CLI

npx tessl i tessl/maven-com-google-genai--google-genai

docs

batch-operations.md

caching.md

chat-sessions.md

client-configuration.md

content-generation.md

embeddings-tokens.md

error-handling.md

file-search-stores.md

files-management.md

image-operations.md

index.md

live-sessions.md

model-tuning.md

operations.md

tools-functions.md

types-reference.md

video-generation.md

tile.json