Diagnose and resolve the Gemini API HTTP 500 'Internal error encountered' and 503 'model is overloaded' errors — check for an outage, retry with exponential backoff, reduce request size, fall back to a lighter model, and add a circuit breaker.