You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Updating to gemini 2.5 flash I get a GenerateContentResponse error #168
Hi, I noticed that since I upgraded to gemini 2.5 flash (gemini-2.5-flash) I sometimes get these errors that I didn't have before with gemini 2.0, do you have any idea what it could be?
The GenerateContentResponse::parts() quick accessor only works for a single candidate,but none were returned. Check the GenerateContentResponse::$promptFeedback to see if the prompt was blocked.
The GenerateContentResponse::text() quick accessor only works when the response contains a valid Part, but none was returned. Check the candidate.safety_ratings to see if the response was blocked.
changed the title [-]Updating to gemini 2.5 I get a GenerateContentResponse error[/-][+]Updating to gemini 2.5 flash I get a GenerateContentResponse error[/+]on Jan 28, 2026
Did anyone work anymore out on this, I've seen a massive increase in these responses over the weekend (same queries as were running last week - are now failing wiht that, but no useful data at all in teh response)
This is usually caused by thinking: gemini-2.5-flash thinks before it answers, and the thinking tokens count towards maxOutputTokens. When the limit is low, the model can use it all on thoughts and stop with finishReason: MAX_TOKENS before writing an answer, so there are no parts to return.
Activity
Plytas commentedon Jan 28, 2026
Hey @ruggiero-m I've noticed this happening too, but haven't had time to investigate it yet. Let me know if you find anything.
[-]Updating to gemini 2.5 I get a GenerateContentResponse error[/-][+]Updating to gemini 2.5 flash I get a GenerateContentResponse error[/+]TimIgoe commentedon Jul 20, 2026
Did anyone work anymore out on this, I've seen a massive increase in these responses over the weekend (same queries as were running last week - are now failing wiht that, but no useful data at all in teh response)
aydinfatih commentedon Oct 12, 2026
This is usually caused by thinking:
gemini-2.5-flashthinks before it answers, and the thinking tokens count towardsmaxOutputTokens. When the limit is low, the model can use it all on thoughts and stop withfinishReason: MAX_TOKENSbefore writing an answer, so there are no parts to return.As of 2.8.0:
text()/parts()error message includes the reason, e.g.... Finish reason: MAX_TOKENS.(fix: Include finish and block reasons in quick accessor errors #189)$response->candidates[0]->finishMessageis available when the API explains why the model stopped (feat: Add response metadata fields #179)To avoid it, increase
maxOutputTokensor limit thinking:See Empty Responses in the README.