Skip to content

GenerateContent method return nothing #584

@jeanphi-baconnais

Description

@jeanphi-baconnais

Hi 👋
I created a tool to create images from a prompt to change elements on a template. I use generateContent method (in synchrone) with some content part.

In the majority of case, Gemini gives me a new image from the template. But depending of the template file, the generateContent method return a object not null but with nothing in parts method.

On templates, I use the same weight (900 ko), I don't understand why Gemini doesn't return anything in some use cases. And I am asking how debug this behavior? Can I check log anywhere? I look in Log explorer but nothing ...

The code in case I make something wrong. I use the API key to execute this. I tried with Vertex but I have others error about configuration on my project.

var response = client.models.generateContent(
            "gemini-2.5-flash-image-preview",
            Content.fromParts(
                    Part.fromBytes(Files.readAllBytes(templateFile), "image/png")),
                    Part.fromBytes(Files.readAllBytes(file1), "image/png")),
                    Part.fromBytes(Files.readAllBytes(file2), "image/png")),
                    Part.fromText(prompt)
            ),
           null);

    for (Part part : Objects.requireNonNull(response.parts())) {
        if (part.inlineData().isPresent()) {

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions