diff --git a/autogpt_platform/backend/backend/blocks/ai_image_customizer.py b/autogpt_platform/backend/backend/blocks/ai_image_customizer.py index d3d8d599a7..3ab8acb31d 100644 --- a/autogpt_platform/backend/backend/blocks/ai_image_customizer.py +++ b/autogpt_platform/backend/backend/blocks/ai_image_customizer.py @@ -24,6 +24,7 @@ from backend.util.file import MediaFileType class GeminiImageModel(str, Enum): NANO_BANANA = "google/nano-banana" + NANO_BANANA_PRO = "google/nano-banana-pro" class OutputFormat(str, Enum): diff --git a/autogpt_platform/backend/backend/blocks/ai_image_generator_block.py b/autogpt_platform/backend/backend/blocks/ai_image_generator_block.py index da87061efe..8c7b6e6102 100644 --- a/autogpt_platform/backend/backend/blocks/ai_image_generator_block.py +++ b/autogpt_platform/backend/backend/blocks/ai_image_generator_block.py @@ -60,6 +60,14 @@ SIZE_TO_RECRAFT_DIMENSIONS = { ImageSize.TALL: "1024x1536", } +SIZE_TO_NANO_BANANA_RATIO = { + ImageSize.SQUARE: "1:1", + ImageSize.LANDSCAPE: "4:3", + ImageSize.PORTRAIT: "3:4", + ImageSize.WIDE: "16:9", + ImageSize.TALL: "9:16", +} + class ImageStyle(str, Enum): """ @@ -98,6 +106,7 @@ class ImageGenModel(str, Enum): FLUX_ULTRA = "Flux 1.1 Pro Ultra" RECRAFT = "Recraft v3" SD3_5 = "Stable Diffusion 3.5 Medium" + NANO_BANANA_PRO = "Nano Banana Pro" class AIImageGeneratorBlock(Block): @@ -261,6 +270,20 @@ class AIImageGeneratorBlock(Block): ) return output + elif input_data.model == ImageGenModel.NANO_BANANA_PRO: + # Use Nano Banana Pro (Google Gemini 3 Pro Image) + input_params = { + "prompt": modified_prompt, + "aspect_ratio": SIZE_TO_NANO_BANANA_RATIO[input_data.size], + "resolution": "2K", # Default to 2K for good quality/cost balance + "output_format": "jpg", + "safety_filter_level": "block_only_high", # Most permissive + } + output = await self._run_client( + credentials, "google/nano-banana-pro", input_params + ) + return output + except Exception as e: raise RuntimeError(f"Failed to generate image: {str(e)}") diff --git a/autogpt_platform/backend/backend/data/block_cost_config.py b/autogpt_platform/backend/backend/data/block_cost_config.py index 43a6547e8c..466caec7ff 100644 --- a/autogpt_platform/backend/backend/data/block_cost_config.py +++ b/autogpt_platform/backend/backend/data/block_cost_config.py @@ -1,5 +1,7 @@ from typing import Type +from backend.blocks.ai_image_customizer import AIImageCustomizerBlock, GeminiImageModel +from backend.blocks.ai_image_generator_block import AIImageGeneratorBlock, ImageGenModel from backend.blocks.ai_music_generator import AIMusicGeneratorBlock from backend.blocks.ai_shortform_video_block import ( AIAdMakerVideoCreatorBlock, @@ -536,4 +538,85 @@ BLOCK_COSTS: dict[Type[Block], list[BlockCost]] = { }, ) ], + AIImageGeneratorBlock: [ + BlockCost( + cost_amount=5, # SD3.5 Medium: ~$0.035 per image + cost_filter={ + "model": ImageGenModel.SD3_5, + "credentials": { + "id": replicate_credentials.id, + "provider": replicate_credentials.provider, + "type": replicate_credentials.type, + }, + }, + ), + BlockCost( + cost_amount=6, # Flux 1.1 Pro: ~$0.04 per image + cost_filter={ + "model": ImageGenModel.FLUX, + "credentials": { + "id": replicate_credentials.id, + "provider": replicate_credentials.provider, + "type": replicate_credentials.type, + }, + }, + ), + BlockCost( + cost_amount=10, # Flux 1.1 Pro Ultra: ~$0.08 per image + cost_filter={ + "model": ImageGenModel.FLUX_ULTRA, + "credentials": { + "id": replicate_credentials.id, + "provider": replicate_credentials.provider, + "type": replicate_credentials.type, + }, + }, + ), + BlockCost( + cost_amount=7, # Recraft v3: ~$0.05 per image + cost_filter={ + "model": ImageGenModel.RECRAFT, + "credentials": { + "id": replicate_credentials.id, + "provider": replicate_credentials.provider, + "type": replicate_credentials.type, + }, + }, + ), + BlockCost( + cost_amount=14, # Nano Banana Pro: $0.14 per image at 2K + cost_filter={ + "model": ImageGenModel.NANO_BANANA_PRO, + "credentials": { + "id": replicate_credentials.id, + "provider": replicate_credentials.provider, + "type": replicate_credentials.type, + }, + }, + ), + ], + AIImageCustomizerBlock: [ + BlockCost( + cost_amount=10, # Nano Banana (original) + cost_filter={ + "model": GeminiImageModel.NANO_BANANA, + "credentials": { + "id": replicate_credentials.id, + "provider": replicate_credentials.provider, + "type": replicate_credentials.type, + }, + }, + ), + BlockCost( + cost_amount=14, # Nano Banana Pro: $0.14 per image at 2K + cost_filter={ + "model": GeminiImageModel.NANO_BANANA_PRO, + "credentials": { + "id": replicate_credentials.id, + "provider": replicate_credentials.provider, + "type": replicate_credentials.type, + }, + }, + ), + ], }