Gemini API (@google/genai) ignoring image generation Aspect Ratio and Resolution settings? Always stuck on defaults
Hey everyone,
I'm building a text-to-image feature using the new official google/genai SDK (^2.3.0) and trying to implement dynamic aspect ratios and resolutions.
While the images are successfully generating, the models seem to completely ignore my dimensional constraints and fall back to their system defaults:
gemini-3.1-flash-image-previewalways outputs a 16:9 landscape image.gemini-2.5-flash-imagealways outputs a 1:1 square image.
Here is the configuration payload I am sending down via my service layer:
{
"serviceTier": "standard",
"responseModalities": [
"TEXT",
"IMAGE"
],
"responseFormat": {
"image": {
"aspectRatio": "9:16",
"imageSize": "2K"
}
}
}
Any help or working code blocks using the standard google/genai package for setting custom ratios dynamically would be highly appreciated!