Skip to content

Updating to gemini 2.5 flash I get a GenerateContentResponse error #168

Closed

Description

@ruggiero-m

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.

Activity

  1. Plytas commented on Jan 28, 2026

    @Plytas
    Collaborator

    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.

  2. 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
  3. TimIgoe commented on Jul 20, 2026

    @TimIgoe

    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)

  4. aydinfatih commented on Oct 12, 2026

    @aydinfatih
    Member

    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.

    As of 2.8.0:

    To avoid it, increase maxOutputTokens or limit thinking:

    new GenerationConfig(
        maxOutputTokens: 2048,
        thinkingConfig: new ThinkingConfig(includeThoughts: false, thinkingBudget: 512),
    );

    See Empty Responses in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions