Browse Source

Honor requested image aspect ratio through Popi gateway

Gemini native image edits can default to the input image dimensions unless the response format also carries the requested image shape. The NewApiWG Gemini payload now sends the existing imageConfig plus responseFormat.image so Popi 16:9 selections survive image-to-image generation while preserving the prior native config path.

Constraint: Gemini image edit defaults can keep the input image dimensions when output format is not explicit
Rejected: Changing composer or node sizing first | the selected aspect ratio already reached the API payload in tests
Confidence: medium
Scope-risk: narrow
Directive: Keep imageConfig and responseFormat in sync for Gemini-native NewApiWG image models
Tested: npm run test:run -- src/app/api/generate/providers/__tests__/newapiwg.test.ts src/app/api/generate/__tests__/route.test.ts
Tested: PROVIDER_MODE=popi NEXT_PUBLIC_PROVIDER_MODE=popi npm run build
feature/add_agent_md
jiajia 2 months ago
parent
commit
3bf78697ae
  1. 4
      src/app/api/generate/__tests__/route.test.ts
  2. 3
      src/app/api/generate/providers/__tests__/newapiwg.test.ts
  3. 6
      src/app/api/generate/providers/newapiwg.ts

4
src/app/api/generate/__tests__/route.test.ts

@ -1096,6 +1096,10 @@ describe("/api/generate route", () => {
aspectRatio: "9:16",
imageSize: "2K",
});
expect(body.generationConfig.responseFormat.image).toMatchObject({
aspectRatio: "9:16",
imageSize: "2K",
});
});
});

3
src/app/api/generate/providers/__tests__/newapiwg.test.ts

@ -265,6 +265,9 @@ describe("NewApiWG generation payloads", () => {
expect(capturedBody!.generationConfig).toMatchObject({
responseModalities: ["IMAGE"],
imageConfig: { aspectRatio: "1:1", imageSize: "2K" },
responseFormat: {
image: { aspectRatio: "1:1", imageSize: "2K" },
},
});
});

6
src/app/api/generate/providers/newapiwg.ts

@ -856,6 +856,12 @@ async function generateImageViaNewApiWGGemini(
aspectRatio,
imageSize,
},
responseFormat: {
image: {
aspectRatio,
imageSize,
},
},
},
...dynamicInputsWithoutPrompt(input),
}),

Loading…
Cancel
Save