I have observed that the Gemini 2.5 Flash Image Preview API randomly produces internal server errors and also responses with no image data. I was handling this using a retry mechanism wherein I retry a request if Internal Server Error occurs or there is no data in the response. I retry 5 times before showing an error. This has reduced the number of errors happening to very less but still a few times I have seen the API fail requests even after 5 retries. Is there a fix for this? I am currently using the gemini API through Google AI studio. Should I be using the API through Vertex AI while running in production to avoid such errors?
This is kind of super frustating. These are very random errors and tonight while I was running the API, the api has been taking forever to produce responses. My server request times out because of the delay. Please help here. I have a product launch soon and I need to figure out how to implement the Gemini 2.5 Flash Image Preview API implementation in a proper manner so that the errors are negligible or impossible.