Hello,
New API user here, trying to generate videos with Veo 2 through google.genai - I’ve just been trying to run the tutorial code in python, shown below.
For my own use case I’ve added
client = genai.Client(api_key = os.getenv("GOOGLE_API_KEY"))
Which works with image_gen. But no matter whether I’m doing txt2video or img2video I get the same error with this tutorial code
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[6], line 16
13 time.sleep(20)
14 operation = client.operations.get(operation)
---> 16 for n, generated_video in enumerate(operation.response.generated_videos):
17 client.files.download(file=generated_video.video)
18 generated_video.video.save(f"video{n}.mp4") # save the video
Is the tutorial broken? am I missing something?
I am able to generate an image with
prompt="Panning wide shot of a calico kitten sleeping in the sunshine"
imagen = client.models.generate_images(
model="imagen-3.0-generate-002",
prompt=prompt,
config=types.GenerateImagesConfig(
number_of_images=1
)
)
imagen.generated_images[0].image.show()
but no videos.. any help would be appreciated .
See tutorial code below
import time
from google import genai
from google.genai import types
client = genai.Client() # read API key from GOOGLE_API_KEY
operation = client.models.generate_videos(
model="veo-2.0-generate-001",
prompt="Panning wide shot of a calico kitten sleeping in the sunshine",
config=types.GenerateVideosConfig(
person_generation="dont_allow", # "dont_allow" or "allow_adult"
aspect_ratio="16:9", # "16:9" or "9:16"
),
)
while not operation.done:
time.sleep(20)
operation = client.operations.get(operation)
for n, generated_video in enumerate(operation.response.generated_videos):
client.files.download(file=generated_video.video)
generated_video.video.save(f"video{n}.mp4") # save the video