imageSize: '2K' parameter ignored in @google/genai SDK but works in AI Studio

Issue Summary

The imageSize: '2K' parameter in imageConfig is completely ignored when using the @google/genai JavaScript SDK, but the same setting works correctly in Google AI Studio web interface.

Environment

  • SDK: @google/genai version 0.14.0 (also tested with latest 1.31.0)
  • Model: gemini-3-pro-image-preview
  • Platform: Node.js / Browser (React + Vite)
  • Use case: E-commerce product photo generation

Expected Behavior

When setting imageSize: '2K', output images should be approximately 2048Γ—2048 pixels (or proportional for other aspect ratios like 3:4 β†’ ~1536Γ—2048).

Actual Behavior

  • SDK returns images at ~896Γ—1200 pixels regardless of imageSize setting
  • The same prompt in AI Studio web interface correctly generates 2K images
  • No error messages or warnings are returned

Code Example

import { GoogleGenAI } from '@google/genai';

const ai = new GoogleGenAI({ apiKey: 'YOUR_API_KEY' });

const response = await ai.models.generateContent({
  model: 'gemini-3-pro-image-preview',
  contents: [
    { text: 'A professional fashion photo of a model wearing a blue jacket, studio lighting' }
  ],
  config: {
    responseModalities: ['TEXT', 'IMAGE'],
    imageConfig: {
      aspectRatio: '3:4',
      imageSize: '2K'  // ← This is being IGNORED
    }
  }
});

// Result: Image is ~896Γ—1200 instead of expected ~1536Γ—2048

What I’ve Verified

  • :white_check_mark: Using uppercase β€˜K’ in imageSize: '2K' (not lowercase)
  • :white_check_mark: Using contents as flat array (not { parts } object)
  • :white_check_mark: responseModalities: ['TEXT', 'IMAGE'] is set correctly
  • :white_check_mark: Tested with multiple aspect ratios (1:1, 3:4, 16:9) - same issue
  • :white_check_mark: Tested with both simple text prompts and image-to-image workflows
  • :white_check_mark: AI Studio generates 2K images with identical settings

Key Observation

The same configuration that fails in the SDK works correctly in AI Studio. This suggests the issue is specific to the JavaScript SDK, not the underlying API.

Questions

  1. Is there a known issue with imageSize parameter in the JS SDK?
  2. Is there a different syntax required for the SDK vs REST API?
  3. Is there an ETA for a fix?

Impact

This limitation prevents using the SDK for high-quality e-commerce product photography workflows where 2K resolution is required.

Thank you for any insights!

I had the same issue. I had to update the library to the latest version. I’m using a npm package, so latest version was β€œ@google/genai”: β€œ^1.32.0” at the time of writing

1 Like

thank you, on my end, I just changed to use the Typescript instead of the JavaScript code, which was a workaround for me.