It appears frequently and does not let me continue using the API, (I use the free version btw but I want to start paying but I do not want to risk if this error continuing) I’m not exaggerating, I can’t use the API. Every two messages I send give me that error.
The http status code 429 usually happens when requests arrive too close to each other, therefore exceed the arrival rate (requests/min) described in Giá của Gemini API | Google AI for Developers
The easiest way to handle this problem is by using retry with exponential back off, the usual approach to dealing with congestion. The google library has retry.Retry()
, an example use can be seen in this cookbook ( Extract structured data using function calling | Gemini API | Google AI for Developers ) right under the heading “The example task”.
You can also roll out your own retry logic if you want to. Hope that helps!
Unfortunately, from my experience, this only retries return codes of 429 and does not retry codes of say 500 or 503. I’ve yet to find a public, standard method for retrying the various codes that Gemini responds with. Upvote this GitHub issue if you’d like to see the Gemini dev team provide us with this critical code.