From 2a9213c5bde5834ce99ee03a070e751918aa69cd Mon Sep 17 00:00:00 2001 From: fasilu Date: Fri, 28 Aug 2026 15:45:24 +0700 Subject: [PATCH] feat(antigravity): map image size to aspect-ratio model suffix Resolve body.size through sizeToAspectRatio and append the ratio as a -WxH suffix so the executor's parseImageConfig picks it up. Also fall back to gemini-3.1-flash-image when a non-image model reaches the image handler. --- open-sse/handlers/imageProviders/antigravity.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/open-sse/handlers/imageProviders/antigravity.js b/open-sse/handlers/imageProviders/antigravity.js index a1f90519..4d4dc367 100644 --- a/open-sse/handlers/imageProviders/antigravity.js +++ b/open-sse/handlers/imageProviders/antigravity.js @@ -1,6 +1,6 @@ // Antigravity image adapter - delegates to the executor for correct request // envelope (project, model, requestType, sessionId) and auth headers. -import { nowSec } from "./_base.js"; +import { nowSec, sizeToAspectRatio } from "./_base.js"; import { getExecutor } from "../../executors/index.js"; // Convert image input (data URI or raw base64) to Gemini inlineData part @@ -31,6 +31,19 @@ export default { const executor = getExecutor("antigravity"); if (!executor) throw new Error("Antigravity executor not found"); + // Ensure we use an image model for image generation + const isImageModel = (m) => /image|imagen|image-generation/i.test(m || ""); + let targetModel = isImageModel(model) ? model : "gemini-3.1-flash-image"; + + // If body.size is provided, resolve aspect ratio and append to model + if (body.size && typeof body.size === "string") { + const ratio = sizeToAspectRatio(body.size); + const suffix = ratio.replace(":", "x"); + if (!targetModel.includes(suffix)) { + targetModel = `${targetModel}-${suffix}`; + } + } + // Build parts: text prompt + optional input image for editing const parts = [{ text: body.prompt }]; const imageInput = body.image || (Array.isArray(body.images) && body.images[0]); @@ -44,7 +57,7 @@ export default { }; const result = await executor.execute({ - model, + model: targetModel, body: chatBody, stream: false, credentials,