Veo 3.0 & Veo 3.1Video Generation
Model Introduction
The Veo series is Google's next-generation video generation models. The series includes models optimized for different purposes, balancing generation quality and speed, supporting the creation of high-quality video content from text and images.
Key Features
- Powerful Video Generation Capabilities: Capable of generating high-resolution videos up to several minutes long, understanding complex scene descriptions and dynamic actions, supporting various artistic styles and visual effects
- Asynchronous Processing Mode: Use the returned task ID for queries
- Time Validity: Generated video links are valid for 24 hours, please save them as soon as possible
API Endpoint
POST https://api.exchangetoken.ai/v1beta/models/veo-3.1-generate-preview:predictLongRunningModel Version Selection
Veo 3.1 is Google's most advanced model, capable of generating high-fidelity 8-second 720p and 1080p videos with stunning realism and natively generated audio. You can access this model programmatically using the Gemini API.
Veo 3.1 Series (Recommended)
veo-3.1-generate-001
- Flagship Quality: Provides the highest standard of video generation quality, suitable for production environments with extremely high detail requirements
veo-3.1-fast-generate-001
- Fast Preview: Optimized for generation speed, maintaining high quality while significantly reducing latency, ideal for rapid prototyping
Veo 3.0 Series (Previous Generation)
veo-3.0-generate-001
- Standard: Previous generation stable model, balancing quality and speed
veo-3.0-fast-generate-001
- Fast: Previous generation low-latency model
Recommendation: New projects should prioritize using Veo 3.1 series models for the best experience.
Veo 3.1 Key Features
Veo 3.1 excels at various visual and cinematic styles, and introduces several new features:
- Portrait Videos: Choose between landscape (
16:9) or portrait (9:16) videos - Video Extension: Extend previously generated videos using Veo
- Keyframe Generation: Generate videos by specifying the first and/or last frame
- Image-Based Guidance: Use reference images to guide the content of generated videos
Text to Video
Feature Description
The following examples demonstrate how to generate high-quality videos from text, including dialogue. The code already includes asynchronous operation handling.
Python Example - Dialogue and Sound Effects
import time
from google import genai
from google.genai import types
client = genai.Client(
http_options={
'base_url': 'https://api.exchangetoken.ai'
},
api_key='sk-xxx' # Replace with your API Key
)
prompt = """A close up of two people staring at a cryptic drawing on a wall, torchlight flickering.
A man murmurs, 'This must be it. That's the secret code.' The woman looks at him and whispering excitedly, 'What did you find?'"""
operation = client.models.generate_videos(
model="veo-3.1-fast-generate-001",
prompt=prompt,
config=types.GenerateVideosConfig(
number_of_videos=1,
resolution="1080p",
duration_seconds=4,
),
)
while not operation.done:
print("Waiting for video generation to complete...")
time.sleep(10)
operation = client.operations.get(operation)
if operation.error:
print(f"Task Failed with Error: {operation.error}")
else:
generated_video = operation.response.generated_videos[0]
client.files.download(file=generated_video.video)
generated_video.video.save("dialogue_example.mp4")
print("Generated video saved to dialogue_example.mp4")REST API Example - Dialogue and Sound Effects
#!/bin/bash
API_KEY="sk-xxxx" # Replace with your API Key
BASE_URL="https://api.exchangetoken.ai/v1beta"
echo "Step 1: Sending video generation request..."
response=$(curl -s -X POST "${BASE_URL}/models/veo-3.1-fast-generate-001:predictLongRunning" \
-H "x-goog-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"instances": [{
"prompt": "A close up of two people staring at a cryptic drawing on a wall, torchlight flickering. A man murmurs, \"This must be it. That'\''s the secret code.\" The woman looks at him and whispering excitedly, \"What did you find?\""
}
]
}')
operation_name=$(echo "${response}" | jq -r .name)
if [ "${operation_name}" == "null" ] || [ -z "${operation_name}" ]; then
echo "Error: Task submission failed! Server response:"
echo "${response}"
exit 1
fi
echo "Task submitted successfully, Operation Name: ${operation_name}"
echo "Step 2: Starting status polling..."
while true; do
status_response=$(curl -s -H "x-goog-api-key: ${API_KEY}" "${BASE_URL}/${operation_name}")
is_done=$(echo "${status_response}" | jq -r .done 2>/dev/null)
if [ -z "$is_done" ]; then
echo "Error: Unable to parse status response, possible network error or invalid API Key."
echo "Server returned: ${status_response}"
exit 1
fi
if [ "${is_done}" = "true" ]; then
echo "Task completed!"
video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
if [ "${video_uri}" != "null" ]; then
echo "Downloading video: ${video_uri}"
curl -L -o dialogue_example.mp4 -H "x-goog-api-key: ${API_KEY}" "${video_uri}"
echo "Download completed: dialogue_example.mp4"
else
echo "Error: Video URI not found, generation may have failed"
echo "${status_response}"
fi
break
else
echo "Task in progress... (waiting 10 seconds)"
fi
sleep 10
doneImage to Video
Feature Description
Generate video content based on input images, supporting the creation of dynamic videos from static images, with customizable actions, styles, and duration. The code already includes asynchronous operation handling.
Python Example - Basic Image to Video
import time
from google import genai
from google.genai import types
client = genai.Client(
http_options={
'base_url': 'https://api.exchangetoken.ai'
},
api_key='sk-xxx' # Replace with your API Key
)
prompt = "Panning wide shot of a calico kitten sleeping in the sunshine"
# First use Gemini to generate an image as input
image = client.models.generate_content(
model="gemini-2.5-flash-image",
contents=prompt,
config={"response_modalities": ['IMAGE']}
)
operation = client.models.generate_videos(
model="veo-3.1-fast-generate-001",
prompt=prompt,
image=image.parts[0].as_image(),
config=types.GenerateVideosConfig(
number_of_videos=1,
resolution="1080p",
duration_seconds=4
),
)
while not operation.done:
print("Waiting for video generation to complete...")
time.sleep(10)
operation = client.operations.get(operation)
if operation.error:
print(f"Task Failed with Error: {operation.error}")
else:
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3_with_image_input.mp4")
print("Generated video saved to veo3_with_image_input.mp4")REST API Example - Basic Image to Video
#!/bin/bash
API_KEY="sk-xxxx" # Replace with your API Key
BASE_URL="https://api.exchangetoken.ai/v1beta"
IMAGE_FILE="input_image.jpg" # Replace with your image file path
if ! [ -r "$IMAGE_FILE" ]; then
echo "Error: Image file not found: $IMAGE_FILE"
exit 1
fi
echo "Step 1: Encoding image file to Base64..."
image_base64=$(base64 -i "$IMAGE_FILE" | tr -d '\n')
echo "Image encoding completed."
echo "Step 2: Sending image-to-video request..."
response=$(curl -s -X POST "${BASE_URL}/models/veo-3.1-fast-generate-001:predictLongRunning" \
-H "x-goog-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"instances": [{
"prompt": "Panning wide shot of a calico kitten sleeping in the sunshine",
"image": {
"inlineData": {
"mimeType": "image/jpeg",
"data": "'"${image_base64}"'"
}
}
}
],
"parameters": {
"resolution": "1080p",
"durationSeconds": 4
}
}')
operation_name=$(echo "${response}" | jq -r .name)
if [ "${operation_name}" == "null" ] || [ -z "${operation_name}" ]; then
echo "Error: Task submission failed! Server response:"
echo "${response}"
exit 1
fi
echo "Task submitted successfully, Operation Name: ${operation_name}"
echo "Step 3: Starting status polling..."
while true; do
status_response=$(curl -s -H "x-goog-api-key: ${API_KEY}" "${BASE_URL}/${operation_name}")
is_done=$(echo "${status_response}" | jq -r .done 2>/dev/null)
if [ -z "$is_done" ]; then
echo "Error: Unable to parse status response."
echo "Server returned: ${status_response}"
exit 1
fi
if [ "${is_done}" = "true" ]; then
echo "Task completed!"
video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
if [ "${video_uri}" != "null" ]; then
echo "Downloading video: ${video_uri}"
curl -L -o veo3_with_image_input.mp4 -H "x-goog-api-key: ${API_KEY}" "${video_uri}"
echo "Download completed: veo3_with_image_input.mp4"
else
echo "Error: Video URI not found."
echo "${status_response}"
fi
break
else
echo "Task in progress... (waiting 10 seconds)"
fi
sleep 10
doneFrame Interpolation
Feature Description
By specifying the first and last frame images, Veo automatically generates intermediate transition frames, creating smooth video effects. Ideal for creating morphing animations, scene transitions, and other effects. The code already includes asynchronous operation handling.
Python Example - Basic Interpolation
import time
from google import genai
from google.genai import types
client = genai.Client(
http_options={
'base_url': 'https://api.exchangetoken.ai'
},
api_key='sk-xxx' # Replace with your API Key
)
prompt = """A cinematic, haunting video. A ghostly woman with long white hair
appears on a rope swing, swaying rhythmically in the eerie silence."""
# Generate first frame image
print("Step 1: Generating first frame image...")
first_image_result = client.models.generate_content(
model="gemini-2.5-flash-image",
contents="A ghostly woman with long white hair sitting on a rope swing in a misty forest",
config={"response_modalities": ['IMAGE']}
)
first_image = first_image_result.parts[0].as_image()
# Generate last frame image
print("Step 2: Generating last frame image...")
last_image_result = client.models.generate_content(
model="gemini-2.5-flash-image",
contents="An empty rope swing swaying gently in a misty forest",
config={"response_modalities": ['IMAGE']}
)
last_image = last_image_result.parts[0].as_image()
# Generate interpolation video using first and last frames
print("Step 3: Generating video with first and last frames (interpolation)...")
operation = client.models.generate_videos(
model="veo-3.1-generate-001",
prompt=prompt,
image=first_image,
config=types.GenerateVideosConfig(
last_frame=last_image,
number_of_videos=1,
duration_seconds=8
),
)
while not operation.done:
print("Waiting for video generation to complete...")
time.sleep(10)
operation = client.operations.get(operation)
if operation.error:
print(f"Task Failed with Error: {operation.error}")
else:
video = operation.response.generated_videos[0]
client.files.download(file=video.video)
video.video.save("veo3.1_with_interpolation.mp4")
print("Generated video saved to veo3.1_with_interpolation.mp4")REST API Example - Basic Interpolation
#!/bin/bash
API_KEY="sk-xxxx" # Replace with your API Key
BASE_URL="https://api.exchangetoken.ai/v1beta"
FIRST_IMAGE="first.jpg" # First frame image path
LAST_IMAGE="last.jpg" # Last frame image path
if ! [ -r "$FIRST_IMAGE" ]; then echo "Error: First frame image not found: $FIRST_IMAGE"; exit 1; fi
if ! [ -r "$LAST_IMAGE" ]; then echo "Error: Last frame image not found: $LAST_IMAGE"; exit 1; fi
echo "Step 1: Encoding image files to Base64..."
first_image_base64=$(base64 -i "$FIRST_IMAGE" | tr -d '\n')
last_image_base64=$(base64 -i "$LAST_IMAGE" | tr -d '\n')
echo "Image encoding completed."
echo "Step 2: Sending interpolation video generation request..."
cat <<EOF > interpolation_payload.json
{
"instances": [{
"prompt": "A cinematic, haunting video. A ghostly woman with long white hair appears on a rope swing, swaying rhythmically in the eerie silence.",
"image": { "inlineData": { "mimeType": "image/jpeg", "data": "$first_image_base64" } }
}],
"parameters": {
"aspectRatio": "16:9",
"resolution": "720p",
"durationSeconds": 8,
"lastFrame": { "inlineData": { "mimeType": "image/jpeg", "data": "$last_image_base64" } }
}
}
EOF
response=$(curl -s -X POST "${BASE_URL}/models/veo-3.1-generate-001:predictLongRunning" \
-H "x-goog-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d @interpolation_payload.json)
rm interpolation_payload.json
operation_name=$(echo "$response" | jq -r .name)
if [ "${operation_name}" == "null" ] || [ -z "${operation_name}" ]; then
echo "Error: Task submission failed!"
echo "$response"
exit 1
fi
echo "Task submitted successfully, Operation Name: ${operation_name}"
echo "Step 3: Starting status polling..."
while true; do
status_response=$(curl -s -H "x-goog-api-key: ${API_KEY}" "${BASE_URL}/${operation_name}")
is_done=$(echo "${status_response}" | jq -r .done 2>/dev/null)
if [ -z "$is_done" ]; then
echo "Error: Unable to parse status response."
echo "Server returned: ${status_response}"
exit 1
fi
if [ "${is_done}" = "true" ]; then
echo "Task completed!"
video_uri=$(echo "${status_response}" | jq -r '.response.generateVideoResponse.generatedSamples[0].video.uri')
if [ "${video_uri}" != "null" ] && [ -n "${video_uri}" ]; then
echo "Downloading video: ${video_uri}"
curl -L -o veo3.1_with_interpolation.mp4 -H "x-goog-api-key: ${API_KEY}" "${video_uri}"
echo "Download completed: veo3.1_with_interpolation.mp4"
else
echo "Error: Video URI not found."
echo "${status_response}"
fi
break
else
echo "Task in progress... (waiting 10 seconds)"
fi
sleep 10
doneVeo API Parameters and Specifications
You can set the following parameters in API requests to control the video generation process.
Parameter List
| Parameter | Description | Veo 3.1 and Veo 3.1 Fast | Veo 3 and Veo 3 Fast |
|---|---|---|---|
prompt | Text description of the video. Supports audio prompts. | string | string |
negativePrompt | Text describing content that should not appear in the video. | string | string |
image | Initial image to animate. | Image object | Image object |
lastFrame | Final image for interpolation video to transition to. Must be used with image parameter. | Image object | Image object |
aspectRatio | Aspect ratio of the video. | "16:9" (default)"9:16" | "16:9" (default)"9:16" |
resolution | Resolution of the video. | "720p" (default)"1080p" (8 seconds only)"4k" (8 seconds only) | "720p" (default)"1080p" (8 seconds only)"4k" (8 seconds only) |
durationSeconds | Duration of the generated video. | "4", "6", "8"Must be "8" when using extension or 1080p/4k resolution | "4", "6", "8"Must be "8" when using extension or 1080p/4k resolution |
personGeneration | Controls person generation. | Text-to-video and extensions: "allow_all"Image-to-video and interpolation: "allow_adult" | Text-to-video: "allow_all"Image-to-video: "allow_adult" |
Notes
- The
seedparameter also applies to Veo 3 models. It doesn't guarantee determinism but can slightly improve it. - You can set parameters in requests to customize video generation. For example, you can specify
negativePromptto guide the model.
License and Terms of Use
Please ensure compliance with Google's terms of use and service agreements. Generated video links are valid for 24 hours, please download and save them promptly.
