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.

1 Like

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:

1 Like

When working with APIs, it’s helpful to implement error handling, backoff mechanisms, and retry logic as standard practice. These are common challenges that most developers face, and building robust solutions for them will make your integration more reliable. If you’d like, I can suggest some approaches for implementing these patterns.

1 Like

Thanks, yes as a developer what you say is obvious. The problem here is not how to handle errors. The problem is that the API doesn’t work.

1 Like

I am now experiencing this with Gemini Flash too. I’d happily pay for it to be reliable.

1 Like