-
Notifications
You must be signed in to change notification settings - Fork 787
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Programming language: Python
- OS: macOS
- Language runtime version: Python
- Package version: google-genai
Issue summary
When using the Python SDK with gemini-3.1-flash-image-preview, image_config.image_size="512px" appears to be ignored.
The generated image is still 1024x1024.
I also tested text to image and image edit paths. In both cases, image_size="512px" still outputs 1024x1024.
Steps to reproduce
- Run this script:
from google import genai
from google.genai import types
from PIL import Image
import io, os
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
response = client.models.generate_content(
model="gemini-3.1-flash-image-preview",
contents=["Studio headshot portrait, realistic face, plain white background, soft lighting"],
config=types.GenerateContentConfig(
response_modalities=["TEXT", "IMAGE"],
image_config=types.ImageConfig(
aspect_ratio="1:1",
image_size="512px",
),
),
)
img_bytes = None
for c in response.candidates or []:
for p in (c.content.parts or []):
if getattr(p, "inline_data", None) and p.inline_data.data:
img_bytes = p.inline_data.data
break
if img_bytes:
break
im = Image.open(io.BytesIO(img_bytes))
print(im.size) # actual output: (1024, 1024)- Repeat with image_size="1K".
Expected behavior
- image_size="512px" should produce ~512x512 output (for aspect_ratio="1:1").
- image_size="1K" should produce a larger output than 512px.
Actual behavior
- Both 512px and 1K return 1024x1024 in my tests.
Additional context
- I am using the latest google-genai package which is 1.65.0
- I initially used "0.5K" (pricing shorthand), then tried to 512px. Same result.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.