"""Video generation (Veo 3.1) – long-running operation with polling."""
import time
from google import genai
from google.genai import types

def main() -> None:
    client = genai.Client()

    prompt = "A cinematic shot of a cat astronaut walking on the moon. Include subtle wind ambience."
    op = client.models.generate_videos(
        model="veo-3.1-generate-preview",
        prompt=prompt,
        config=types.GenerateVideosConfig(resolution="1080p"),
    )

    while not op.done:
        time.sleep(10)
        op = client.operations.get(op)

    video = op.response.generated_videos[0].video
    client.files.download(file=video)
    video.save("out.mp4")
    print("Saved out.mp4")

if __name__ == "__main__":
    main()
