From e43eec260a0aec5853f31c341e69a15c186a5ac0 Mon Sep 17 00:00:00 2001 From: cwandev <18888351756@163.com> Date: Thu, 19 Mar 2026 22:09:23 +0800 Subject: [PATCH] fix(baoyu-image-gen): narrow OpenRouter Gemini ratios --- skills/baoyu-image-gen/scripts/providers/openrouter.test.ts | 6 ++++++ skills/baoyu-image-gen/scripts/providers/openrouter.ts | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/skills/baoyu-image-gen/scripts/providers/openrouter.test.ts b/skills/baoyu-image-gen/scripts/providers/openrouter.test.ts index f0e2dfc..eda5437 100644 --- a/skills/baoyu-image-gen/scripts/providers/openrouter.test.ts +++ b/skills/baoyu-image-gen/scripts/providers/openrouter.test.ts @@ -12,6 +12,7 @@ import { } from "./openrouter.ts"; const GEMINI_MODEL = "google/gemini-3.1-flash-image-preview"; +const GEMINI_25_MODEL = "google/gemini-2.5-flash-image-preview"; const FLUX_MODEL = "black-forest-labs/flux.2-pro"; function makeArgs(overrides: Partial = {}): CliArgs { @@ -78,6 +79,7 @@ test("OpenRouter size and aspect helpers infer expected defaults", () => { assert.equal(getAspectRatio(GEMINI_MODEL, makeArgs({ size: "2048x1024" })), null); assert.equal(getAspectRatio(GEMINI_MODEL, makeArgs({ size: "1600x900" })), "16:9"); assert.equal(getAspectRatio(GEMINI_MODEL, makeArgs({ size: "1024x4096" })), "1:4"); + assert.equal(getAspectRatio(GEMINI_25_MODEL, makeArgs({ size: "1024x4096" })), null); assert.equal(getAspectRatio(FLUX_MODEL, makeArgs({ size: "1024x4096" })), null); }); @@ -85,6 +87,10 @@ test("OpenRouter validates explicit aspect ratios against model support", () => assert.doesNotThrow(() => validateArgs(GEMINI_MODEL, makeArgs({ aspectRatio: "1:4" })), ); + assert.throws( + () => validateArgs(GEMINI_25_MODEL, makeArgs({ aspectRatio: "1:4" })), + /does not support aspect ratio 1:4/, + ); assert.throws( () => validateArgs(FLUX_MODEL, makeArgs({ aspectRatio: "1:4" })), /does not support aspect ratio 1:4/, diff --git a/skills/baoyu-image-gen/scripts/providers/openrouter.ts b/skills/baoyu-image-gen/scripts/providers/openrouter.ts index 93db5f4..86e0db7 100644 --- a/skills/baoyu-image-gen/scripts/providers/openrouter.ts +++ b/skills/baoyu-image-gen/scripts/providers/openrouter.ts @@ -45,7 +45,7 @@ export function getDefaultModel(): string { } function normalizeModelId(model: string): string { - return model.trim().toLowerCase(); + return model.trim().toLowerCase().split(":")[0]!; } export function isGeminiImageModel(model: string): boolean { @@ -54,7 +54,8 @@ export function isGeminiImageModel(model: string): boolean { } function getSupportedAspectRatios(model: string): Set { - if (!isGeminiImageModel(model)) { + const normalized = normalizeModelId(model); + if (normalized !== "google/gemini-3.1-flash-image-preview") { return new Set(COMMON_ASPECT_RATIOS); }