Constant 503's from gemini-1.5-pro API

I have been using the Gemini API for about a week now and it seems extremely unreliable. I would say about half of my requests fail with {“status”:503,“statusText”:“Service Unavailable”}. Google expects people to build on this API but I don’t really see how it’s possible given the flakeyness. Checking the status of the Gemini service says everything’s ok, but it’s clearly not. Has there been any word form Google on this? Thanks.

The Gemini API is still in its early stages and Google is actively working to improve its stability. In the meantime, here’s a robust way to handle requests:

def call_gemini_with_retry(prompt, max_retries=3, delay=1):
    for attempt in range(max_retries):
        try:
            response = model.generate_content(prompt)
            return response
        except Exception:
            time.sleep(delay * (attempt + 1))
    return None

This retry mechanism with exponential backoff helps maintain reliable service while Google continues scaling their infrastructure. The API’s performance is expected to improve significantly in the coming weeks.

I found some link that could maybe help too: