{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "dfc39e85"
},
"source": [
"### Copyright 2026 Google LLC."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "f34a315f"
},
"outputs": [],
"source": [
"# @title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "41d4f1c0"
},
"source": [
"# Get started with Video generation using Veo\n",
"\n",
"
\n",
"\n",
"_If you're reading this notebook on Github, open it in Colab by clicking the above button to see the generated videos._"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3e37ea00"
},
"source": [
"> **Note:** Veo is a paid only feature. This notebook won't run with the Free Tier. (cf. [pricing](https://ai.google.dev/pricing#veo2) for more details).\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "7be3a94c"
},
"outputs": [],
"source": [
"# Change that value if you want to run the colab\n",
"I_am_aware_that_veo_is_a_paid_feature = False # @param {type:\"boolean\"}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "841dfb52"
},
"source": [
"## What's Veo?\n",
"\n",
"Veo enables creators to create high quality videos with incredible detail, minimal artifacts, and extended durations in resolutions up to 1080p. Veo supports both text-to-video and images-to-video.\n",
"\n",
"With [Veo 3](https://ai.google.dev/gemini-api/docs/video), you can create videos with:\n",
"* **Advanced language understanding**: Veo deeply understands natural language and visual semantics, capturing the nuance and tone of complex prompts to render intricate details in extended scenes, including cinematic terms like \"timelapse\" or \"aerial shots.\"\n",
"* **Unprecedented creative control**: Veo provides an unprecedented level of creative control, understanding prompts for all kinds of cinematic effects, like timelapses or aerial shots of a landscape.\n",
"* **Videos with audio**: Veo 3 generates videos with audio automatically, with no additional effort from the developer.\n",
"* **More accurate video controls**: Veo 3 is more accurate on lighting, accurate physics, and camera controls."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "d824166b"
},
"source": [
"**Veo 3.1** brings new capabilities:\n",
"* **Starting and ending frames**: Control how the video starts... and ends! ([jump directly to this part](#last_frame))\n",
"* **Image-based direction**: Give up to 3 references to Veo (character, locations, props...) and let it create a video using them ([jump directly to this part](#r2v))\n",
"* **Extend videos**: Add 7s more second to your videos up to 141 seconds long ones. ([jump directly to this part](#extend))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0a01551c"
},
"source": [
"The Veo 3 family of models includes [**Veo 3/3.1**](https://ai.google.dev/gemini-api/docs/video?example=dialogue#veo-3), [**Veo 3.1 Lite**](https://ai.google.dev/gemini-api/docs/video?example=dialogue#veo-3-1-lite), and [**Veo 3/3.1 Fast**](https://ai.google.dev/gemini-api/docs/video?example=dialogue#veo-3-fast), which are faster and more accessible versions of the models. The Veo Lite and Fast models are ideal for backend services that programmatically generate ads, tools for rapid A/B testing of creative concepts, or apps that need to quickly produce social media content. **Veo 3.1 Lite** is particularly cost-effective, optimized for high-throughput 720p and 1080p video generation."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "d8f810b7"
},
"source": [
"**Safety is a core focus**, with robust measures to prevent inappropriate or harmful content, and all generated videos are digitally watermarked with [Google DeepMind’s SynthID](https://deepmind.google/science/synthid/)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c16c0d75"
},
"source": [
"Note that the previous model generation, [**Veo 2**](https://ai.google.dev/gemini-api/docs/video?example=dialogue#veo-2), is still available for developers via the Gemini API for a while. However, unlike Veo 3, videos generated by Veo 2 do not contain audio."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c9c89862"
},
"source": [
"# Setup"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8b94202c"
},
"source": [
"### Install SDK\n",
"\n",
"Install the SDK from [PyPI](https://github.com/googleapis/python-genai)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "dbd10aac"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.3/45.3 kB\u001b[0m \u001b[31m1.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m237.3/237.3 kB\u001b[0m \u001b[31m13.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h"
]
}
],
"source": [
"%pip install -U -q \"google-genai>=1.44.0\" # Minimum version 1.44 for video extension"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "b666495e"
},
"source": [
"### Setup your API key and initialize client\n",
"\n",
"To run the following cell, your API key must be stored it in a Colab Secret named `GOOGLE_API_KEY`. If you don't already have an API key, or you're not sure how to create a Colab Secret, see [Authentication ](../quickstarts/Authentication.ipynb) for an example."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4f6b9008"
},
"outputs": [],
"source": [
"from google.colab import userdata\n",
"from google import genai\n",
"from google.genai import types\n",
"\n",
"GEMINI_API_KEY = userdata.get('GEMINI_API_KEY')\n",
"client = genai.Client(api_key=GEMINI_API_KEY)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "6ca1bd17"
},
"source": [
"### Select the Veo model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "fb65c0c1"
},
"outputs": [],
"source": [
"VEO_MODEL_ID = \"veo-3.1-lite-generate-preview\" # @param [\"veo-3.1-lite-generate-preview\", \"veo-3.1-fast-generate-preview\", \"veo-3.1-generate-preview\"] {\"allow-input\":true, isTemplate: true}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "056b3852"
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "306fef02"
},
"source": [
"# Text-to-video\n",
"\n",
"Describe your desired scene, whether crafted by you or with Gemini's assistance, and Veo 3 brings it to life."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "637f998f"
},
"source": [
"### Prompting Tips for Veo\n",
"To get the most out of Veo, consider incorporating specific video terminology into your prompts. Veo understands a wide range of terms related to:\n",
"\n",
"* **Shot composition**: Specify the framing and number of subjects in the shot (e.g., \"*single shot*\", \"*two shot*\", \"*over-the-shoulder shot*\").\n",
"* **Camera positioning and movement**: Control the camera's location and movement using terms like \"*eye level*\", \"*high angle*\", \"*worms eye*\", \"*dolly shot*\", \"*zoom shot*\", \"*pan shot,\" and \"*tracking shot*\".\n",
"* **Focus and lens effects**: Use terms like \"*shallow focus*\", \"*deep focus*\", \"*soft focus*\", \"*macro lens*\", and \"*wide-angle lens*\" to achieve specific visual effects.\n",
"* **Overall style and subject**: Guide Veo's creative direction by specifying styles like \"*sci-fi*\", \"*romantic comedy*\", \"*action movie*\" or \"*animation*\". You can also describe the subjects and backgrounds you want, such as \"*cityscape*\", \"*nature*\", \"*vehicles*\", or \"animals.\"\n",
"\n",
"Check the [Veo prompt guide](https://ai.google.dev/gemini-api/docs/video#prompt-guide) for more details and tips.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "7d9386a7"
},
"source": [
"### Optional parameters\n",
"The prompt is the only mandatory parameters, the others are all optional.\n",
"\n",
"* **negative_prompt**: What you don't want to see in the video,\n",
"* **person_generation**: Tell you model if it's allowed to generate adults in the videos or not. Children are always blocked,\n",
"* **duration_seconds**: 4, 6 or 8s with Veo 3.1 (always 8s for Veo 3 and 7s when extending)\n",
"* **aspect ratio**: Either `16:9` (landscape) or `9:16` (portrait),\n",
"* **resolution**: Either `720p` or `1080p`\n",
"\n",
"More details about each parameters in the related section of the [documentation](https://ai.google.dev/gemini-api/docs/video#veo-model-parameters)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "e278bf12"
},
"source": [
"### Create a video from a simple text prompt"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8625bb4a"
},
"source": [
"It takes about a minute for the video to be generated."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "601782a2"
},
"outputs": [],
"source": [
"if not I_am_aware_that_veo_is_a_paid_feature:\n",
" print(\"Veo is a paid feature. Please change the variable 'I_am_aware_that_veo_is_a_paid_feature' to True if you are okay with paying to run it.\")\n",
"\n",
"else:\n",
" import time\n",
"\n",
" prompt = \"a close-up shot of a golden retriever playing in a field of sunflowers\" # @param {type: \"string\"}\n",
"\n",
" # Optional parameters\n",
" negative_prompt = \"barking, woofing\" # @param {type: \"string\"}\n",
" aspect_ratio = \"16:9\" # @param [\"16:9\",\"9:16\"]\n",
" resolution = \"1080p\" # @param [\"720p\",\"1080p\"]\n",
"\n",
" operation = client.models.generate_videos(\n",
" model=VEO_MODEL_ID,\n",
" prompt=prompt,\n",
" config=types.GenerateVideosConfig(\n",
" aspect_ratio=aspect_ratio,\n",
" resolution=resolution,\n",
" negative_prompt=negative_prompt,\n",
" ),\n",
" )\n",
"\n",
" # Waiting for the video(s) to be generated\n",
" while not operation.done:\n",
" time.sleep(20)\n",
" operation = client.operations.get(operation)\n",
" print(operation)\n",
"\n",
" print(operation.result.generated_videos)\n",
"\n",
" for n, generated_video in enumerate(operation.result.generated_videos):\n",
" client.files.download(file=generated_video.video)\n",
" generated_video.video.save(f'video{n}.mp4') # Saves the video(s)\n",
" display(generated_video.video.show()) # Displays the video(s) in a notebook"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "f4bddb78"
},
"source": [
"##### Watch a sample generation 🎥\n",
"\n",
"🍿 The video you will generate will be similar to this: [A golden retriever playing in a field of sunflowers](https://storage.googleapis.com/generativeai-downloads/gemini-cookbook/videos/dog_sunflowers.mp4).\n",
"\n",
"