Hint at a missing or invalid API key when a provider returns a 401

Merged
PU
9d ago
+199-10

A missing API key currently logs only HTTP request returned status code 401. That message does not point to the cause.

A 401 now throws InvalidApiKeyException, which extends RequestException. Existing catch blocks keep working, and the message keeps the response summary:

Missing or invalid API key for AI provider [openai]. HTTP request returned status code 401:
{"error":{"message":"Incorrect API key provided."}}

The class overrides prepareMessage() because RequestException::report() rebuilds the message from it.

[!NOTE]
Gemini (403 for a missing key, 400 for an invalid key) and xAI (400 for an invalid key) do not use a 401. Their errors are unchanged.