An images API request (and the image MCP tool, which goes through it)
for a Gemini image model had its OpenAI size folded into an aspect
ratio alone, so the model drew at its default 1K and no size above 1K
could be asked (#3936): drawGemini sent generationConfig.imageConfig
without an imageSize, and drawCodeAssist sent no imageConfig at all.
Both now build the imageConfig an images API size asks a Gemini image
model for: the ratio the size is nearest, with an imageSize beside it
when the size asks past the model's 1K default - the smallest of
Gemini's buckets whose long side covers the size asked (2048 -> 2K,
4096x4096 -> 4K). Only 2K and 4K go out: a size at or under the 1K
default is drawn at anyway, and imageSize isn't every image model's
(Vertex lists 1K, 2K, 4K), so nothing is asked for what the default
gives. drawCodeAssist carries it in Request.ImageConfig, the field a
Gemini client's own imageConfig arrives in, which Code Assist's
envelope already forwards.
Chat completions is left as it is: OpenRouter's image_config documents
an aspect_ratio only, and an undocumented field risks a strict relay's
refusal.
A Gemini 2.x image model (gemini-2.5-flash-image) draws at 1K only,
and Google documents imageSize for the Gemini 3 image models, so a 2.x
model is still sent the ratio alone (added in the port; the magpie tool's
own example size, 1536x1024, would otherwise ask it for 2K).
Run (mote): go test -tags nogui -count=1 -run
'TestImagesAPISize|TestGeminiImageConfig|TestAspectOf|TestAspectAmong|Draw|Antigravity'
./internal/gateway/ ok; gofmt -l clean; go vet -tags nogui
./internal/gateway/ clean.
Broken by hand: draw.go put back to origin/main, both new tests FAIL
(4096x4096 sent {"aspectRatio":"1:1"}, Code Assist sent no imageConfig);
the 2.x guard removed, the gemini-2.5-flash-image case FAILs with
imageSize 4K.
Not tried: a live Google API key or Antigravity sign-in (none here), so
whether each back-end draws at the bucket asked is unchecked.
Fixes#3936
Generated-by: GLM-5.3-Flash (ZCode)
Co-authored-by: ggbdpq <ggbdpq@gmail.com>