I'm trying to generate images using the imagen-3.0-generate-002 model by running a python script in my github workflow and I'm encountering the following error:
❌ Error generating image: 429 Quota exceeded for aiplatform.googleapis.com/generate_content_requests_per_minute_per_project_per_base_model with base model: imagen-3.0-generate. Please submit a quota increase request. https://cloud.google.com/vertex-ai/docs/generative-ai/quotas-genai.
I'm able to make normal text requests to vertex ai without issues. I've even tried to request image generation in isolation so as to not hit rate limits. My project quota indicates a value of 10 with none used. I also have billing enabled. Why am I still getting the error? My request code is below:
import os
import json
import base64
from datetime import datetime
from pathlib import Path
from google.cloud import aiplatform
from vertexai.preview.generative_models import GenerativeModel
import vertexai
def generate_single_image():
"""Generate a single AI image for testing"""
try:
print("\n🎨 Initializing AI image generation...")
# Initialize Vertex AI
project_id = os.getenv('GCP_PROJECT_ID')
location = os.getenv('GCP_LOCATION')
vertexai.init(project=project_id, location=location)
image_model = GenerativeModel("imagen-3.0-generate-002")
prompt = f"""
An apple riding a motorcycle
"""
response = image_model.generate_content(
prompt,
generation_config={
"temperature": 0.8,
}
)
image_bytes = response.candidates[0].content.parts[0]
image_base64 = base64.b64encode(image_bytes).decode('utf-8')
return image_base64
except Exception as e:
print(f"\n❌ Error generating image: {str(e)}")
raise e
def main():
try:
print("Starting image generation...")
image_data = generate_single_image()
except Exception as e:
print(f"\n❌ Error: {str(e)}")
raise e
if __name__ == "__main__":
main()
Hi @anupdsouza,
Welcome to Google Cloud Community!
It looks like you are encountering a "429 Quota exceeded" error when generating images using the Vertex AI Imagen model. Despite having an underutilized quota (0% usage with a limit of 10 requests per minute), text requests work fine, but image generation fails. You have ensured billing is enabled, and your rate limits should be sufficient.
Here are the potential ways that might help with your use case:
For more detailed information, you can refer to the following documentation on Google Cloud's quotas and billing:
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.
I'm also encountering this issue. Interestingly, if I generate the image using Vertex AI Studio, the quota is utilized. But when I'm using API, it's underutilized and I'm encountering 429 error.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |