Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Quota limit with imagen Error code 429 despite unused quota

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.

Screenshot 2025-02-08 at 8.44.52 PM.png

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()

 

 

1 2 1,637
2 REPLIES 2