How to for generating videos from text prompts using Vertex AI's Veo model through Kong AI Gateway. Set response_modalities to ["VIDEO"] and specify the duration.
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"
}
)
response = client.models.generate_content(
model="veo-001",
contents="A cat playing with a ball of yarn in slow motion",
config={
"response_modalities": ["VIDEO"],
"duration": 5
}
)
# Extract and save video
for part in response.candidates[0].content.parts:
if part.inline_data:
with open("generated_video.mp4", "wb") as f:
f.write(part.inline_data.data)
print("Video saved!")