Gemini 2.0 with Grounding - 429 Quota exhausted error

I have Pay-as-you-go plan enabled.

I’ve tried new Gemini 2.0 API with multimodal inputs (text and image) and grounding search.
On 13th of December (when it was first released) it worked all fine, I got results with the help of grounding search but now I get 429 quota exhausted responses.
I haven’t used the API extensively as well, I was still experimenting with the API, in total I could’ve made about 10-20 requests max.

Here’s my code:

import PIL.Image
from google import genai
from google.genai.types import Tool, GenerateContentConfig, GoogleSearch

client = genai.Client(api_key=os.environ.get("GEMINI_API_KEY"))
google_search_tool = Tool(google_search=GoogleSearch())
model = "gemini-2.0-flash-exp"

async def get_company_website(image: bytes) -> str:
    """
    Searches website URL from given company image
    """
    image = PIL.Image.open(io.BytesIO(image))
    # If using a single image, place the text prompt after the image.
    response = await client.aio.models.generate_content(
        model=model,
        contents=[ image, PROMPT ],
        config=GenerateContentConfig(
            # max_output_tokens=200,
            tools=[google_search_tool],
            response_modalities=["TEXT"]
        )
    )

    return response.text

I’m using google-genai==0.2.2

It all works fine without GoogleSearch enabled

What am I missing here?

I also experienced this, in my case it was a matter of waiting it out. Strange behaviour still. Please see: Response 429 when using Grounding, otherwise fine

429 errors are thrown when the rate limit is exceeded. Typically, you may be sending too many requests per minute with the free tier Gemini API. You mentioned that this worked on On 13th of December, before you started getting 429 quota exhausted responses. Are you still getting the errors?

Thanks for reaching out Martijn! I had looked into your case as well!

1 Like

Thanks for reaching out, camadi!

I had wrong API keys