or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

batch-operations.mdcaching.mdchat-sessions.mdclient-configuration.mdcontent-generation.mdembeddings-tokens.mderror-handling.mdfile-search-stores.mdfiles-management.mdimage-operations.mdindex.mdlive-sessions.mdmodel-tuning.mdoperations.mdtools-functions.mdtypes-reference.mdvideo-generation.md

video-generation.mddocs/

0

# Video Generation

1

2

Generate videos from text prompts or images using Veo models.

3

4

## Core Imports

5

6

```java

7

import com.google.genai.types.GenerateVideosOperation;

8

import com.google.genai.types.GenerateVideosConfig;

9

import com.google.genai.types.GenerateVideosSource;

10

import com.google.genai.types.GeneratedVideo;

11

import com.google.genai.types.Video;

12

import com.google.genai.types.Image;

13

```

14

15

## Generate Videos

16

17

```java { .api }

18

public GenerateVideosOperation generateVideos(

19

String model,

20

GenerateVideosSource source,

21

GenerateVideosConfig config);

22

23

public GenerateVideosOperation generateVideos(

24

String model,

25

String prompt,

26

Image image,

27

Video video,

28

GenerateVideosConfig config);

29

```

30

31

## Text to Video

32

33

```java

34

GenerateVideosConfig config = GenerateVideosConfig.builder()

35

.numberOfVideos(1)

36

.durationSeconds(5)

37

.enhancePrompt(true)

38

.build();

39

40

GenerateVideosOperation operation = client.models.generateVideos(

41

"veo-2.0-generate-001",

42

"A cat walking through a futuristic city",

43

null,

44

config

45

);

46

47

// Poll until complete

48

while (!operation.done().isPresent()) {

49

Thread.sleep(10000);

50

operation = client.operations.getVideosOperation(operation, null);

51

}

52

53

operation.response().ifPresent(response -> {

54

response.generatedVideos().ifPresent(videos -> {

55

for (GeneratedVideo video : videos) {

56

System.out.println("Video: " + video.video().orElse(null));

57

}

58

});

59

});

60

```

61

62

## Image to Video

63

64

```java

65

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

66

67

GenerateVideosConfig config = GenerateVideosConfig.builder()

68

.numberOfVideos(1)

69

.durationSeconds(5)

70

.build();

71

72

GenerateVideosOperation operation = client.models.generateVideos(

73

"veo-2.0-generate-001",

74

"Animate this image with gentle camera movement",

75

image,

76

config

77

);

78

```

79

80

## Download Generated Video

81

82

```java

83

operation.response().ifPresent(response -> {

84

response.generatedVideos().ifPresent(videos -> {

85

GeneratedVideo video = videos.get(0);

86

client.files.download(

87

video,

88

"path/to/output.mp4",

89

null

90

);

91

});

92

});

93

```

94

95

## Video Configuration

96

97

```java { .api }

98

public final class GenerateVideosConfig {

99

public static Builder builder();

100

101

public Optional<Integer> numberOfVideos();

102

public Optional<Integer> durationSeconds();

103

public Optional<Boolean> enhancePrompt();

104

public Optional<String> aspectRatio();

105

public Optional<HttpOptions> httpOptions();

106

}

107

```

108