google_ai: Improve error messages and handle retries (#64865)

This improves error message handling for Google AI, previously we were
not classifying at all and were always using
`LanguageModelCompletionError::Other(...)`. This has the positive side
effect that we now automatically retry when a model is overloaded (which
very frequently happens with the free flash models).

Before:
```
failed to stream completion: error during streamGenerateContent, status code: 400, body: {
  "error": {
    "code": 400,
    "message": "API key not valid. Please pass a valid API key.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_INVALID",
        "domain": "googleapis.com",
        "metadata": {
          "service": "generativelanguage.googleapis.com"
        }
      },
      {
        "@type": "type.googleapis.com/google.rpc.LocalizedMessage",
        "locale": "en-US",
        "message": "API key not valid. Please pass a valid API key."
      }
    ]
  }
}
```

After:
```
API key not valid. Please pass a valid API key.
```

Another example, previously we would just show "failed to stream
completion":

<img width="685" height="65" alt="image"
src="https://github.com/user-attachments/assets/76ddde40-9dc0-4093-a6d5-ee3a9dfb7a32"
/>


Release Notes:

- Improved error handling when using Google AI as a provider
fa6aeecf2aBennet Bo Fenner committed on 9/28/2026, 9:19:01 AM· committed by GitHubparentee43be1
2 files changedLine totals unavailable