Prompt Writing Guide
Writing high-quality prompts is key to getting excellent videos. Here are detailed explanations for each element:
Prompt Structure
Subject Description
Actions & Behavior
Environment & Scene
Camera Movement
Visual Style
Clearly describe the main object or character in the video Good Examples:
“A small orange cat”
“A young girl wearing a red dress”
“A silver sports car”
Avoid:
“Something”
“Some animals”
Specifically describe the subject’s actions and behavior Good Examples:
“Slowly walking”
“Running fast”
“Dancing gracefully”
Avoid:
“Moving around”
“Doing something”
Describe the background and environment in detail Good Examples:
“A sunny garden”
“City streets on a rainy night”
“Beach at sunset”
Avoid: Describe the camera’s movement Good Examples:
“Camera follows”
“Top-down view”
“360-degree rotation”
Optional Element Specify the desired visual style Good Examples:
“4K HD, cinematic quality”
“Animation style”
“Retro film texture”
Optional Element
Excellent Prompt Examples
Prompt Enhancement Feature
Enabling enhance_prompt allows AI to automatically optimize your prompts and improve generation quality
When to Use Prompt Enhancement
Recommended
First time using the API
Simple prompts
Want better results
Unsure how to describe
Can Disable
Need precise control
Already have well-crafted prompts
Specific style requirements
Technical descriptions
Reference Image Usage
Image Requirements
Requirement Description Format JPG, PNG, WebP Size Single image not exceeding 10MB Quantity Maximum 5 images Resolution Recommended 1024x1024 or higher Content Clear, relevant reference materials
Usage Tips
Choose High-Quality Images
Use clear, high-resolution images as references
Maintain Style Consistency
Multiple images should maintain visual style consistency
Relevance First
Choose reference images most relevant to the target video
Avoid Conflicts
Image content should not conflict with text description
Polling Strategy
Recommended Polling Implementation
import time
import math
def exponential_backoff_polling ( client , task_id , initial_interval = 5 , max_interval = 60 ):
"""
Exponential backoff polling strategy
"""
interval = initial_interval
attempt = 0
while True :
try :
status_data = client.get_status(task_id)
status = status_data.get( 'status' )
if status == 'completed' :
return status_data[ 'result' ]
elif status == 'failed' :
raise Exception ( f "Generation failed: { status_data.get( 'error' ) } " )
# Exponential backoff
time.sleep(interval)
attempt += 1
interval = min (initial_interval * math.pow( 1.5 , attempt), max_interval)
except Exception as e:
print ( f "Polling error: { e } " )
time.sleep(interval)
Polling Parameters Recommendations
Initial Interval: 5 seconds
Maximum Interval: 60 seconds
Backoff Factor: 1.5
Maximum Wait: 30 minutes
Error Handling
Retry Strategy
def retry_with_backoff ( func , max_retries = 3 , backoff_factor = 2 ):
"""
Retry mechanism with backoff
"""
for attempt in range (max_retries):
try :
return func()
except Exception as e:
if attempt == max_retries - 1 :
raise
wait_time = backoff_factor ** attempt
print ( f "Failed, retrying in { wait_time } seconds..." )
time.sleep(wait_time)
Common Error Handling
Network Errors
API Errors
Task Failure
try :
result = client.submit_task(prompt)
except requests.exceptions.ConnectionError:
print ( "Network connection failed, please check network" )
except requests.exceptions.Timeout:
print ( "Request timeout, please retry later" )
try :
result = client.submit_task(prompt)
except Exception as e:
if "QUOTA_EXCEEDED" in str (e):
print ( "Quota exhausted" )
elif "INVALID_PROMPT" in str (e):
print ( "Invalid prompt" )
status = client.get_status(task_id)
if status[ 'status' ] == 'failed' :
error_info = status.get( 'error' , {})
print ( f "Task failed: { error_info.get( 'message' ) } " )
# Can try resubmitting
Batch Processing
When generating multiple videos, batch processing is recommended:
async def batch_process_videos ( prompts , max_concurrent = 5 ):
"""
Batch process video generation
"""
semaphore = asyncio.Semaphore(max_concurrent)
async def process_one ( prompt ):
async with semaphore:
return await client.submit_and_wait(prompt)
tasks = [process_one(prompt) for prompt in prompts]
return await asyncio.gather( * tasks)
Resource Management
Note concurrent limit: Maximum 10 tasks simultaneously
Cost Optimization
Model Selection Strategy
def choose_model ( requirements ):
"""
Intelligently choose model based on requirements
"""
if requirements.get( 'need_fast' ):
return 'veo3-fast'
elif requirements.get( 'high_quality' ):
return 'veo3-pro'
elif requirements.get( 'precise_control' ):
return 'veo3-pro-frames'
else :
return 'veo3' # Default to standard version
Testing Recommendations
Use veo3 or veo3-fast for testing during development, choose appropriate model based on needs in production
Monitoring and Logging
Recommended Logging
import logging
from datetime import datetime
class VEOLogger :
def __init__ ( self ):
self .logger = logging.getLogger( 'veo_api' )
def log_task_submission ( self , task_id , prompt , model ):
self .logger.info( f "Task submitted: { task_id } " )
self .logger.debug( f "Prompt: { prompt[: 50 ] } ..." )
self .logger.debug( f "Model: { model } " )
def log_task_completion ( self , task_id , duration , video_url ):
self .logger.info( f "Task completed: { task_id } " )
self .logger.info( f "Duration: { duration } s" )
self .logger.debug( f "Video URL: { video_url } " )
Monitoring Metrics
Task success rate
Average generation time
API response time
Error rate statistics
Cost tracking