Skip to main content

VertexAIVeoToolkit

A toolkit for interacting with Google Vertex AI Veo video generation. This toolkit provides methods for generating videos using Google’s Veo, supporting both text-to-video and image-to-video generation with various customization options.

init

Initialize the Vertex AI Veo toolkit. Parameters:
  • project_id (Optional[str]): Google Cloud project ID. If not provided, will use the default project from environment. (default: :obj:None)
  • location (str): Google Cloud location for the API calls. (default: :obj:"us-central1")
  • model_id (str): The Veo model ID to use. Options include “veo-2.0-generate-001” or “veo-3.0-generate-preview”. (default: :obj:"veo-2.0-generate-001")
  • output_storage_uri (Optional[str]): Cloud Storage URI to save output videos. If not provided, returns video bytes. (default: :obj:None)
  • timeout (Optional[float]): Request timeout in seconds. (default: :obj:None)

generate_video_from_text

Generate video from text prompt using Vertex AI Veo. Parameters:
  • text_prompt (str): The text prompt to guide video generation.
  • response_count (int): Number of videos to generate (1-4). (default: :obj:1)
  • duration (int): Video duration in seconds (5-8). (default: :obj:5)
  • aspect_ratio (str): Video aspect ratio. Options: “16:9”, “9:16”. (default: :obj:"16:9")
  • negative_prompt (Optional[str]): What to avoid in the video. (default: :obj:None)
  • person_generation (str): Person safety setting. Options: “allow_adult”, “dont_allow”. (default: :obj:"allow_adult")
Returns: Dict[str, Any]: A dictionary containing:
  • ‘success’ (bool): Whether the operation was successful
  • ‘videos’ (List[Dict]): List of generated video data
  • ‘metadata’ (Dict): Additional metadata from the response
  • ‘error’ (str): Error message if operation failed

generate_video_from_image

Generate video from image and text prompt using Vertex AI Veo. Parameters:
  • image_path (str): Path to the input image file (local or GCS URI).
  • text_prompt (str): The text prompt to guide video generation.
  • response_count (int): Number of videos to generate (1-4). (default: :obj:1)
  • duration (int): Video duration in seconds (5-8). (default: :obj:5)
  • aspect_ratio (str): Video aspect ratio. Options: “16:9”, “9:16”. (default: :obj:"16:9")
  • negative_prompt (Optional[str]): What to avoid in the video. (default: :obj:None)
  • person_generation (str): Person safety setting. (default: :obj:"allow_adult")
Returns: Dict[str, Any]: A dictionary containing:
  • ‘success’ (bool): Whether the operation was successful
  • ‘videos’ (List[Dict]): List of generated video data
  • ‘metadata’ (Dict): Additional metadata from the response
  • ‘error’ (str): Error message if operation failed

extend_video

Extend an existing video using Vertex AI Veo. Parameters:
  • video_uri (str): Cloud Storage URI of the video to extend.
  • text_prompt (str): The text prompt to guide video extension.
  • duration (int): Duration to extend in seconds (5-8). (default: :obj:5)
  • aspect_ratio (str): Video aspect ratio. (default: :obj:"16:9")
  • negative_prompt (Optional[str]): What to avoid in the extension. (default: :obj:None)
Returns: Dict[str, Any]: A dictionary containing:
  • ‘success’ (bool): Whether the operation was successful
  • ‘videos’ (List[Dict]): List of extended video data
  • ‘metadata’ (Dict): Additional metadata from the response
  • ‘error’ (str): Error message if operation failed

_process_image

Process image file and return base64 encoded data and MIME type.

_parse_video_response

Parse the video generation response.

get_tools

Returns: List[FunctionTool]: List of available function tools.

get_async_tools

Returns: List[FunctionTool]: List of available async function tools.