Generate Images and Videos at Low Cost with Vertex AI

Harnessing the power of Google’s state-of-the-art generative AI models, Imagen 4 for image creation and Google Veo for video production, is now more accessible than ever through the Vertex AI platform. By leveraging the Vertex AI API and employing strategic cost-management techniques, you can generate high-quality visual content affordably. This guide provides a comprehensive overview of pricing, free-tier options, and cost-optimization strategies to help you get started.

Understanding the Pricing Structure

The cost of using Imagen 4 and Google Veo on Vertex AI is based on a pay-as-you-go model. You are billed for the amount of processing power used to generate your images and videos.

Imagen Pricing (table from Google Cloud pricing on accessed data. For up-to-date pricing, see here):

ModelFeatureDescriptionInputOutputPrice
Imagen 4 UltraImage generationGenerate an imageText promptImage$0.06 per image
Imagen 4Image generationGenerate an imageText promptImage$0.04 per image
Imagen 4 FastImage generationGenerate an imageText promptImage$0.02 per image
Imagen 3Image generationGenerate an image
Edit an image
Customize an image
Text promptImage$0.04 per image
Imagen 3 FastImage generationGenerate an imageText promptImage$0.02 per image
Imagen 2, ImagenImage generationGenerate an imageText promptImage$0.020 per image
Image editingEdit an image using mask free or mask approachImage/Text promptImage$0.020 per image
UpscalingIncrease resolution of a generated image to 2k and 4kImageImage$0.003 per image
Fine-tuningEnable a “subject” provided by the user to used in Imagen prompts (few shot training)Subject(s) with text identifier and 4-8 images per subjectFine-tuned model (after training with user provided subjects)$ per node hour (Vertex AI custom training pricing)
Visual CaptioningGenerate a short or long text caption for an imageImageText caption$0.0015/image
Visual Q&AProvide an answer based on a question referencing an imageImage/Text promptText answer$0.0015/image

Google Veo pricing: The following table is from Google Cloud at accessed data. For updated pricing, see here.

ModelFeatureDescriptionInputOutputPrice
Veo 3Video generationGenerate videos from a text prompt or reference imageText/Image promptVideo$0.50/second
Veo 3Video + Audio generationGenerate video with synchronized speech/sound effects from a text prompt or reference imageText/Image promptVideo + Audio$0.75/second
Veo 2Video generationGenerate videos from a text prompt or reference imageText/Image promptVideo$0.50/second
Veo 2Advanced ControlsGenerate videos through start and end frame interpolation, extend generated videos, and apply camera controlsText/Image/Video promptVideo$0.50/second

It’s important to consult the official Google Cloud Vertex AI pricing page for the most current and detailed information, as these rates are subject to change.

Take Advantage of the Free Tier and Credits

For new users, Google Cloud offers a generous free tier that can significantly reduce your initial costs.

  • $300 in Free Credits: New Google Cloud customers are eligible for $300 in free credits that can be used over 90 days. These credits can be applied to Vertex AI services, including Imagen and Veo, allowing for substantial experimentation and initial project development without any out-of-pocket expense.
  • Free Usage: Some Vertex AI services may also have a free usage tier, which allows for a certain amount of free processing per month. Be sure to check the specifics for the models you intend to use.

But what’s Vertex AI?

The Vertex AI API is a unified interface for Google Cloud’s comprehensive machine learning platform, allowing developers and data scientists to programmatically access every step of the ML lifecycle. It provides the tools to build, train, and deploy custom machine learning models, as well as leverage powerful pre-trained models like Gemini for multimodal tasks, Imagen for image generation, and Codey for code assistance. By interacting with this single API, users can manage datasets, run training jobs, evaluate model performance, and deploy models to scalable endpoints for real-time predictions, effectively streamlining the entire process from experimentation to production.

Strategies for Cost Optimization

Beyond the free tier, several strategies can help you manage and minimize your expenses when using Vertex AI for media generation.

  • Choose the Right Model: Vertex AI often provides different versions of its models. For less complex tasks, using a standard or “fast” version of a model can be more cost-effective than a more powerful, and consequently more expensive, version.
  • Optimize Prompts: Well-crafted, detailed prompts can lead to better results in the first attempt, reducing the need for multiple generations and the associated costs. Experiment with prompt engineering to achieve your desired output efficiently.
  • Control Generation Parameters: Adjusting parameters such as image resolution or video length can directly impact the cost. For drafts or internal reviews, consider generating lower-resolution images or shorter video clips to save on processing fees.
  • Leverage Caching: For identical prompts, Vertex AI may offer cached results, which can reduce the cost of repeated requests.
  • Monitor Usage and Set Budgets: Regularly monitor your Vertex AI usage through the Google Cloud Console. You can set up budget alerts to notify you when your spending reaches certain thresholds, helping you avoid unexpected costs.
  • Use Spot Instances (for advanced workflows): For large-scale, non-critical batch processing, consider using spot instances for your underlying compute resources. These instances are offered at a significant discount compared to on-demand pricing, though they can be preempted.

Getting Started with the Vertex AI API

To begin generating images and videos programmatically, you’ll need to use the Vertex AI API. Here’s a simplified overview of the steps involved:

  1. Set up your Google Cloud Project: Create a new project in the Google Cloud Console and enable the Vertex AI API on Google Cloud Console.
  2. For an interactive interface, you can use Google Cloud’s Vertex AI Studio. This doesn’t require coding. However, the coding API is very convenient when the number of images and videos to be generated is on a large scale.
  3. Authentication: Set up authentication for your environment. This typically involves creating a service account and using its credentials to authenticate your API requests.

Important: It is crucial to disable or delete active Vertex AI resources after you have finished using them, primarily for cost management and security. Leaving resources such as a deployed model on an active endpoint is akin to leaving a high-performance computer running continuously—it incurs charges even when idle, as it reserves resources to be ready to serve predictions. Similarly, running notebook instances or other jobs will continue to accumulate costs. By proactively shutting down endpoints, deleting unused models and datasets, and disabling the API on projects that are no longer active, you prevent unnecessary expenditure and reduce your project’s potential security footprint, ensuring you only pay for the computational resources you actively consume. The API can be disabled here. Also, you need to disable Cloud Storage to avoid storage charge. You can do that here.

For use with the coding interface:

  1. Install the Client Libraries: Google provides client libraries for various programming languages, such as Python, to simplify interaction with the Vertex AI API.
  2. Make API Calls: Use the client libraries to make API calls to the Imagen and Veo models, providing your prompts and desired parameters.

Here are some conceptual code snippets to illustrate the process:

Python example for Imagen 4 image generation:

Python

from google.cloud import aiplatform
from google.protobuf import struct_pb2

# Initialize the Vertex AI client
aiplatform.init(project='your-gcp-project-id', location='us-central1')

# Define the model and prompt
model = aiplatform.Model('projects/your-gcp-project-id/locations/us-central1/models/imagen@005')
prompt = "A futuristic cityscape at sunset, with flying cars and neon lights"

# Generate the image
response = model.predict(instances=[struct_pb2.Value(string_value=prompt)])

# Process the response to get the image data

Conceptual Python example for Google Veo video generation:

Python

from google.cloud import aiplatform

# Initialize the Vertex AI client
aiplatform.init(project='your-gcp-project-id', location='us-central1')

# Define the model and prompt
model = aiplatform.Model('projects/your-gcp-project-id/locations/us-central1/models/veo@latest')
prompt = "A short, cinematic clip of a majestic eagle soaring over a mountain range"

# Generate the video
response = model.predict(instances=[{'prompt': prompt}])

# Process the response to get the video data


Discover more from Science Comics

Subscribe to get the latest posts sent to your email.

Leave a Reply

error: Content is protected !!