Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style: nano banana support `aspect_ratio` (#9528)

sxjeruae3ed6ec4714
diff --git a/packages/model-bank/src/aiModels/google.ts b/packages/model-bank/src/aiModels/google.ts
index d1162159d52..10953530305 100644
--- a/packages/model-bank/src/aiModels/google.ts
+++ b/packages/model-bank/src/aiModels/google.ts
@@ -366,6 +366,28 @@ const googleChatModels: AIChatModelCard[] = [
'Nano Banana 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。',
displayName: 'Nano Banana',
enabled: true,
+ id: 'gemini-2.5-flash-image',
+ maxOutput: 8192,
+ pricing: {
+ units: [
+ { name: 'textInput', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'imageInput', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'textOutput', rate: 2.5, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'imageOutput', rate: 30, strategy: 'fixed', unit: 'millionTokens' },
+ ],
+ },
+ releasedAt: '2025-08-26',
+ type: 'chat',
+ },
+ {
+ abilities: {
+ imageOutput: true,
+ vision: true,
+ },
+ contextWindowTokens: 32_768 + 8192,
+ description:
+ 'Nano Banana 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。',
+ displayName: 'Nano Banana (Preview)',
id: 'gemini-2.5-flash-image-preview',
maxOutput: 8192,
pricing: {
@@ -805,22 +827,62 @@ const imagenBaseParameters: ModelParamsSchema = {
prompt: { default: '' },
};
+const NANO_BANANA_ASPECT_RATIOS = [
+ '1:1', // 1024x1024
+ '2:3', // 832x1248
+ '3:2', // 1248x832
+ '3:4', // 864x1184
+ '4:3', // 1184x864
+ '4:5', // 896x1152
+ '5:4', // 1152x896
+ '9:16', // 768x1344
+ '16:9', // 1344x768
+ '21:9', // 1536x672
+];
+
+const nanoBananaParameters: ModelParamsSchema = {
+ aspectRatio: {
+ default: '1:1',
+ enum: NANO_BANANA_ASPECT_RATIOS,
+ },
+ imageUrls: {
+ default: [],
+ },
+ prompt: { default: '' },
+};
+
/* eslint-disable sort-keys-fix/sort-keys-fix */
const googleImageModels: AIImageModelCard[] = [
{
displayName: 'Nano Banana',
- id: 'gemini-2.5-flash-image-preview:image',
+ id: 'gemini-2.5-flash-image:image',
enabled: true,
type: 'image',
description:
'Nano Banana 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。',
releasedAt: '2025-08-26',
+ parameters: nanoBananaParameters,
+ pricing: {
+ units: [
+ { name: 'textInput', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'textOutput', rate: 2.5, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'imageOutput', rate: 30, strategy: 'fixed', unit: 'millionTokens' },
+ ],
+ },
+ },
+ {
+ displayName: 'Nano Banana (Preview)',
+ id: 'gemini-2.5-flash-image-preview:image',
+ type: 'image',
+ description:
+ 'Nano Banana 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。',
+ releasedAt: '2025-08-26',
parameters: CHAT_MODEL_IMAGE_GENERATION_PARAMS,
pricing: {
units: [
{ name: 'textInput', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },
{ name: 'textOutput', rate: 2.5, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'imageOutput', rate: 3, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'imageOutput', rate: 30, strategy: 'fixed', unit: 'millionTokens' },
],
},
},
diff --git a/packages/model-runtime/src/providers/google/createImage.ts b/packages/model-runtime/src/providers/google/createImage.ts
index e14e42b1202..9fbea6dc91c 100644
--- a/packages/model-runtime/src/providers/google/createImage.ts
+++ b/packages/model-runtime/src/providers/google/createImage.ts
@@ -1,4 +1,4 @@
-import { Content, GoogleGenAI, Part } from '@google/genai';
+import { Content, GenerateContentConfig, GoogleGenAI, Part } from '@google/genai';
import { convertGoogleAIUsage } from '../../core/usageConverters/google-ai';
import { CreateImagePayload, CreateImageResponse } from '../../types/image';
@@ -141,10 +141,19 @@ async function generateImageByChatModel(
},
];
+ const config: GenerateContentConfig = {
+ responseModalities: ['Image'],
+ ...(params.aspectRatio
+ ? {
+ imageConfig: {
+ aspectRatio: params.aspectRatio,
+ },
+ }
+ : {}),
+ };
+
const response = await client.models.generateContent({
- config: {
- responseModalities: ['Image'],
- },
+ config,
contents,
model: actualModel,
});