Skip to content

gemini-3.1-flash-image-preview ignores imageConfig.imageSize — always returns 1K #1461

Description

@didistudy

Environment details

  • SDK: @google/genai v1.45.0 and v1.48.0 (tested both, same behavior)
  • Endpoint: Vertex AI (vertexai: true, API version v1beta1)
  • Location: global
  • Platform: Node.js 20, Cloud Run (europe-west1)

Summary

gemini-3.1-flash-image-preview silently ignores the imageConfig.imageSize parameter in generateContent requests. The model always produces ~1K resolution output (928x1152) regardless of whether imageSize is set to "2K" or "4K".

The same code path works correctly with gemini-3-pro-image-preview, which respects imageSize and produces 4K output as expected.

Steps to reproduce

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

const client = new GoogleGenAI({ vertexai: true, project: 'my-project', location: 'global' });

const result = await client.models.generateContent({
  model: 'gemini-3.1-flash-image-preview',
  config: {
    responseModalities: ['TEXT', 'IMAGE'],
    imageConfig: {
      imageSize: '2K',   // Also tried '4K' — same result
    },
    temperature: 0.4,
  },
  contents: [
    {
      role: 'user',
      parts: [
        { text: 'A product photo of a dress on a model' },
        { inlineData: { data: '<base64_image>', mimeType: 'image/png' } },
      ],
    },
  ],
});

// Result: image is always ~1K (928x1152), never 2K or 4K

Expected behavior

Output image should match the requested imageSize:

  • "2K" → largest dimension ~2048px
  • "4K" → largest dimension ~4096px

Per Google's documentation: "Gemini 3 image models generate 1K images by default but can also output 2K, 4K, and 512 (0.5K) images."

The model page also lists "New support for 0.5K, 2K and 4K" as a feature.

Actual behavior

Output is always ~1K (928x1152) regardless of imageSize value. No error is returned — the parameter is silently ignored.

Comparison with gemini-3-pro-image-preview

Using the exact same code with model: 'gemini-3-pro-image-preview' produces correct 4K output. This confirms:

  • The SDK correctly serializes imageConfig.imageSize into the request
  • The Vertex AI endpoint accepts the parameter
  • The issue is specific to gemini-3.1-flash-image-preview

Verification

We inspected the SDK source and confirmed that imageConfigToVertex in @google/genai correctly maps imageSize to generationConfig.imageConfig.imageSize in the Vertex AI REST request body. The transformation function is identical between SDK v1.45.0 and v1.48.0 — this is not an SDK serialization issue.

Impact

Users requesting 2K or 4K resolution receive 1K output without any error indication.

Metadata

Metadata

Assignees

Labels

api: vertex-aiIssues related to the Vertex AI API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions