Skip to content

Commit 643aea8

Browse files
feat(backend/blocks): Add google banana pro (#11425)
This PR adds the latest google banana pro image generator and editor to the platform and fixes up some of the prices for the image generation models I asked for ``Generate a image of a dog on a skateboard`` and this is what i got: <img width="2048" height="2048" alt="image" src="https://github.com/user-attachments/assets/9b6c16d8-df8f-4fb6-a009-d6d342f9beb7" /> ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] Test the image generator and image editor block using the latest google banana pro model and it works --------- Co-authored-by: Abhimanyu Yadav <[email protected]>
1 parent 3b092f3 commit 643aea8

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

autogpt_platform/backend/backend/blocks/ai_image_customizer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
class GeminiImageModel(str, Enum):
2626
NANO_BANANA = "google/nano-banana"
27+
NANO_BANANA_PRO = "google/nano-banana-pro"
2728

2829

2930
class OutputFormat(str, Enum):

autogpt_platform/backend/backend/blocks/ai_image_generator_block.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ class ImageSize(str, Enum):
6060
ImageSize.TALL: "1024x1536",
6161
}
6262

63+
SIZE_TO_NANO_BANANA_RATIO = {
64+
ImageSize.SQUARE: "1:1",
65+
ImageSize.LANDSCAPE: "4:3",
66+
ImageSize.PORTRAIT: "3:4",
67+
ImageSize.WIDE: "16:9",
68+
ImageSize.TALL: "9:16",
69+
}
70+
6371

6472
class ImageStyle(str, Enum):
6573
"""
@@ -98,6 +106,7 @@ class ImageGenModel(str, Enum):
98106
FLUX_ULTRA = "Flux 1.1 Pro Ultra"
99107
RECRAFT = "Recraft v3"
100108
SD3_5 = "Stable Diffusion 3.5 Medium"
109+
NANO_BANANA_PRO = "Nano Banana Pro"
101110

102111

103112
class AIImageGeneratorBlock(Block):
@@ -261,6 +270,20 @@ async def generate_image(self, input_data: Input, credentials: APIKeyCredentials
261270
)
262271
return output
263272

273+
elif input_data.model == ImageGenModel.NANO_BANANA_PRO:
274+
# Use Nano Banana Pro (Google Gemini 3 Pro Image)
275+
input_params = {
276+
"prompt": modified_prompt,
277+
"aspect_ratio": SIZE_TO_NANO_BANANA_RATIO[input_data.size],
278+
"resolution": "2K", # Default to 2K for good quality/cost balance
279+
"output_format": "jpg",
280+
"safety_filter_level": "block_only_high", # Most permissive
281+
}
282+
output = await self._run_client(
283+
credentials, "google/nano-banana-pro", input_params
284+
)
285+
return output
286+
264287
except Exception as e:
265288
raise RuntimeError(f"Failed to generate image: {str(e)}")
266289

autogpt_platform/backend/backend/data/block_cost_config.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Type
22

3+
from backend.blocks.ai_image_customizer import AIImageCustomizerBlock, GeminiImageModel
4+
from backend.blocks.ai_image_generator_block import AIImageGeneratorBlock, ImageGenModel
35
from backend.blocks.ai_music_generator import AIMusicGeneratorBlock
46
from backend.blocks.ai_shortform_video_block import (
57
AIAdMakerVideoCreatorBlock,
@@ -536,4 +538,85 @@
536538
},
537539
)
538540
],
541+
AIImageGeneratorBlock: [
542+
BlockCost(
543+
cost_amount=5, # SD3.5 Medium: ~$0.035 per image
544+
cost_filter={
545+
"model": ImageGenModel.SD3_5,
546+
"credentials": {
547+
"id": replicate_credentials.id,
548+
"provider": replicate_credentials.provider,
549+
"type": replicate_credentials.type,
550+
},
551+
},
552+
),
553+
BlockCost(
554+
cost_amount=6, # Flux 1.1 Pro: ~$0.04 per image
555+
cost_filter={
556+
"model": ImageGenModel.FLUX,
557+
"credentials": {
558+
"id": replicate_credentials.id,
559+
"provider": replicate_credentials.provider,
560+
"type": replicate_credentials.type,
561+
},
562+
},
563+
),
564+
BlockCost(
565+
cost_amount=10, # Flux 1.1 Pro Ultra: ~$0.08 per image
566+
cost_filter={
567+
"model": ImageGenModel.FLUX_ULTRA,
568+
"credentials": {
569+
"id": replicate_credentials.id,
570+
"provider": replicate_credentials.provider,
571+
"type": replicate_credentials.type,
572+
},
573+
},
574+
),
575+
BlockCost(
576+
cost_amount=7, # Recraft v3: ~$0.05 per image
577+
cost_filter={
578+
"model": ImageGenModel.RECRAFT,
579+
"credentials": {
580+
"id": replicate_credentials.id,
581+
"provider": replicate_credentials.provider,
582+
"type": replicate_credentials.type,
583+
},
584+
},
585+
),
586+
BlockCost(
587+
cost_amount=14, # Nano Banana Pro: $0.14 per image at 2K
588+
cost_filter={
589+
"model": ImageGenModel.NANO_BANANA_PRO,
590+
"credentials": {
591+
"id": replicate_credentials.id,
592+
"provider": replicate_credentials.provider,
593+
"type": replicate_credentials.type,
594+
},
595+
},
596+
),
597+
],
598+
AIImageCustomizerBlock: [
599+
BlockCost(
600+
cost_amount=10, # Nano Banana (original)
601+
cost_filter={
602+
"model": GeminiImageModel.NANO_BANANA,
603+
"credentials": {
604+
"id": replicate_credentials.id,
605+
"provider": replicate_credentials.provider,
606+
"type": replicate_credentials.type,
607+
},
608+
},
609+
),
610+
BlockCost(
611+
cost_amount=14, # Nano Banana Pro: $0.14 per image at 2K
612+
cost_filter={
613+
"model": GeminiImageModel.NANO_BANANA_PRO,
614+
"credentials": {
615+
"id": replicate_credentials.id,
616+
"provider": replicate_credentials.provider,
617+
"type": replicate_credentials.type,
618+
},
619+
},
620+
),
621+
],
539622
}

0 commit comments

Comments
 (0)