Firebase AI (Gemini Flash) throwing DECODE_PREEMPTED and UNAVAILABLE errors during Android app image analysis

Hello,

UNAVAILABLE (503) errors are unrelated to your quota. They mean the service is temporarily overloaded and can’t serve your request, and they are more common at certain times of the day. Please see this pinned post for how to handle them. In short: add backoff and retry in your app, starting with a small number of retries and a short timeout and increasing them if the errors continue.

INTERNAL (500) errors mean an unexpected error occurred on the server, and the API errors guide recommends retrying the request.

Your app calls Gemini through Firebase AI Logic. For questions about the Firebase SDK or the Firebase console, please contact Firebase Support.