-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Open
Copy link
Labels
Milestone
Description
How to for generating animated videos from static images using Vertex AI's Veo model through Kong AI Gateway. Combine image data with a text prompt to create the animation.
Python script:
from google import genai
client = genai.Client(
vertexai=True,
project="your-project-id",
location="us-central1",
http_options={
"api_version": "v1",
"base_url": "http://localhost:8000/gemini"
}
)
with open("input_image.jpg", "rb") as f:
image_data = f.read()
response = client.models.generate_content(
model="veo-001",
contents=[
{
"inline_data": {
"mime_type": "image/jpeg",
"data": image_data
}
},
"Animate this image: make the water ripple and clouds move"
]
)
# Extract and save video
for part in response.candidates[0].content.parts:
if part.inline_data:
with open("animated_video.mp4", "wb") as f:
f.write(part.inline_data.data)
print("Animated video saved!")