Video generation with Veo 3.1
Generate high-fidelity videos with Google Veo 3.1 for text-to-video, image-to-video, or video-to-video workflows. Use this when users request video creation from prompts, images, or existing footage with synchronized audio.
/plugin marketplace add jongwony/cc-plugin/plugin install google@cc-pluginThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/api-examples.mdreferences/prompting-guide.mdGenerate high-fidelity videos with Google Veo 3.1 via API. Supports text-to-video, image-to-video, and video-to-video workflows with advanced cinematography control and synchronized audio generation.
uv pip install google-genai
from google import genai
from google.genai import types
import time
import os
# Initialize client
client = genai.Client(
vertexai=True,
project=os.getenv("GOOGLE_CLOUD_PROJECT"), # Set via environment variable
location="us-central1"
)
# Generate video from text
operation = client.models.generate_videos(
model='veo-3.1-generate-preview',
prompt='A neon hologram of a cat driving at top speed',
config=types.GenerateVideosConfig(
number_of_videos=1,
duration_seconds=5,
# enhance_prompt defaults to True and cannot be disabled in Veo 3.1
),
)
# Poll until complete (typically 2-5 minutes)
while not operation.done:
time.sleep(20)
operation = client.operations.get(operation)
# Check for errors before accessing response
if operation.error:
raise Exception(f"Video generation failed: {operation.error}")
# Save the generated video
video = operation.response.generated_videos[0].video
with open('output.mp4', 'wb') as f:
f.write(video.video_bytes)
For consistent, high-quality results, structure prompts using:
[Cinematography] + [Subject] + [Action] + [Context] + [Style & Ambiance]
Medium shot, a tired corporate worker, rubbing his temples in exhaustion,
in front of a bulky 1980s computer in a cluttered office late at night.
The scene is lit by the harsh fluorescent overhead lights and the green
glow of the monochrome monitor. Retro aesthetic, shot as if on 1980s
color film, slightly grainy.
For detailed cinematography language (camera movements, composition, lens techniques), see references/prompting-guide.md.
Generate video from text prompt only.
operation = client.models.generate_videos(
model='veo-3.1-generate-preview',
prompt='Your detailed prompt here',
config=types.GenerateVideosConfig(
number_of_videos=1,
duration_seconds=6,
aspect_ratio='16:9',
resolution='1080p',
),
)
# Poll and save
while not operation.done:
time.sleep(20)
operation = client.operations.get(operation)
# Check for errors
if operation.error:
raise Exception(f"Video generation failed: {operation.error}")
video = operation.response.generated_videos[0].video
with open('output.mp4', 'wb') as f:
f.write(video.video_bytes)
Animate a source image with optional prompt guidance.
from PIL import Image as PILImage
# Load image with proper MIME type
with open('path/to/image.jpg', 'rb') as f:
image_data = f.read()
image = types.Image(
image_bytes=image_data,
mime_type='image/jpeg' # or 'image/png' for PNG files
)
# Detect aspect ratio from image
pil_image = PILImage.open('path/to/image.jpg')
width, height = pil_image.size
aspect_ratio = '16:9' if width > height else '9:16'
operation = client.models.generate_videos(
model='veo-3.1-generate-preview',
prompt='Slow dolly shot moving closer, cinematic lighting',
image=image,
config=types.GenerateVideosConfig(
number_of_videos=1,
duration_seconds=5,
aspect_ratio=aspect_ratio,
resolution='1080p',
),
)
# Poll and save
while not operation.done:
time.sleep(20)
operation = client.operations.get(operation)
# Check for errors
if operation.error:
raise Exception(f"Video generation failed: {operation.error}")
video = operation.response.generated_videos[0].video
with open('output.mp4', 'wb') as f:
f.write(video.video_bytes)
Edit or transform existing video content.
video_input = types.Video(
uri="gs://bucket-name/video.mp4", # GCS URI for Vertex AI
)
operation = client.models.generate_videos(
model='veo-3.1-generate-preview',
prompt='Transform into cyberpunk style with neon lights',
video=video_input,
config=types.GenerateVideosConfig(
number_of_videos=1,
duration_seconds=5,
),
)
# Poll and save
while not operation.done:
time.sleep(20)
operation = client.operations.get(operation)
# Check for errors
if operation.error:
raise Exception(f"Video generation failed: {operation.error}")
video = operation.response.generated_videos[0].video
with open('output.mp4', 'wb') as f:
f.write(video.video_bytes)
Veo 3.1 generates complete soundtracks based on text instructions.
Use quotation marks for specific speech:
A woman says, "We have to leave now."
Describe sounds explicitly:
SFX: thunder cracks in the distance
Define background soundscape:
Ambient noise: the quiet hum of a starship bridge
For complex projects requiring precise control, use multi-step workflows combining Veo with Gemini 2.5 Flash Image.
See references/prompting-guide.md for detailed workflow instructions.
| Situation | Reference |
|---|---|
| Need cinematography vocabulary or camera techniques | prompting-guide.md |
| Want advanced audio direction or negative prompts | prompting-guide.md |
| Need multi-shot workflows with Gemini integration | prompting-guide.md |
| Need complete working code examples | api-examples.md |
| Implementing error handling or retry logic | api-examples.md |
| Using advanced features (first/last frame, ingredients) | api-examples.md |
For detailed prompting techniques and advanced workflows, consult the reference guides.
If you encounter Permission 'aiplatform.endpoints.predict' denied:
Authenticate: Set up Application Default Credentials
gcloud auth application-default login
Add IAM role: Grant Vertex AI access to your account
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="user:YOUR_EMAIL" \
--role="roles/aiplatform.user"
Enable API: Activate Vertex AI API for your project
gcloud services enable aiplatform.googleapis.com --project=PROJECT_ID
This skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.