Skip to content

How do we go about specifying the aspect ratio of the generated image? #550

@JamesDerrickHH

Description

@JamesDerrickHH

Hi, I've managed to get image generation working well on an Azure Function, using this library, but currently always get a square, 1024x1024, image returned. Is there any way to change this?

Looking in the API Reference documentation there is an ImageConfig object, which allows aspectRatio, however, I get typescript errors when I try to use this

e.g.

        const model = vertexAI.getGenerativeModel({
            model: 'gemini-2.5-flash-image',
            generationConfig: {
                imageConfig: {
                    aspectRatio: "16:9",
                    imageSize: "1K"
                }
            }
        })

But I get the following typescript error
Object literal may only specify known properties, and 'imageConfig' does not exist in type 'GenerationConfig'.

Any help would be greatly appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: aiplatformIssues related to the googleapis/nodejs-vertexai API.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