For the past few weeks, the Gemini API (specifically gemini-2.5-pro) has been completely unreliable for my application. Initially, I thought these issues were temporary, but they persist, suggesting a possible change in the Gemini API infrastructure or behavior.
My setup, which was previously working fine with the same prompts and keys, then all of the sudden now fails inconsistently across multiple API calls, with some succeeding and others returning empty responses or 500 errors. I’m seeking assistance to diagnose and resolve this.
Issue Description
The API intermittently returns:
- Empty responses: response.text is undefined, with candidates[0].content: {role: “model”} but no parts array
- HTTP 500 errors: “An internal error has occurred. Please retry or report…”, indicating server-side issues.
- Response structure:
{
"candidates": [{"content": {"role": "model"}, "finishReason": "STOP", "index": 0}],
"modelVersion": "gemini-2.5-pro",
"usageMetadata": {
"promptTokenCount": 20,
"totalTokenCount": 183,
"thoughtsTokenCount": 163
}
}
RAW RESPONSE (3388ms):
Response object keys: [ ‘candidates’, ‘modelVersion’, ‘usageMetadata’ ]
Full response: {
“candidates”: [
{
“content”: {
“role”: “model”
},
“finishReason”: “STOP”,
“index”: 0
}
],
“modelVersion”: “gemini-2.5-pro”,
“usageMetadata”: {
“promptTokenCount”: 20,
“totalTokenCount”: 183,
“promptTokensDetails”: [
{
“modality”: “TEXT”,
“tokenCount”: 20
}
],
“thoughtsTokenCount”: 163
}
}
RESPONSE ANALYSIS:
response.text: undefined = “undefined”
response.candidates: true (length: 1)
candidates[0] keys: [ ‘content’, ‘finishReason’, ‘index’ ]
candidates[0].content: { role: ‘model’ }
candidates[0].finishReason: “STOP”
what is going on?