Google 的 Nano Banana 是谷歌最新推出的图像生成与编辑模型,其正式名称为 Gemini 2.5 Flash Image 。该模型是谷歌在多模态AI领域的重要进展,专注于图像生成和编辑,具备强大的图像生成、编辑和多轮交互能力 。Nano Banana 被认为是目前最优秀的AI图像工具之一,其性能强大,效果出色,尤其在图像生成、编辑、动画制作等方面表现突出。 最近这个Nano Banana非常火爆,考虑到这个模型国内很多小伙伴不能直接访问,今天我也来凑个热闹,使用dify做了个插件,然后在dify平台上实现了这个Nano Banana。我们看一下生成的效果。

上面这个图是我韩国的学生证做的手办。
我的学生证
哈哈是不是很帅。
在上一张美女手办

是不是很漂亮,那么这个工作流是什么样子的呢?

通过上面的工作流我们可以制作基于Nano Banana任何风格的图片(电商场景、广告创意、摄影技巧、社媒内容、动漫创作、建筑景观、3D效果、实用变现、其他功能)。那么话不多说,下面带大家一步一步制作。
2.工作流制作
插件安装
在工作流制作之前我们这里需要提前下载插件。目前这个插件我已经开源上传到github上,dify插件市场我也会提交上传,不过这个需要等待审核。时间关系我们就通过插件下载本地上传方式来安装这个插件。
打开我们本地或者私有化部署的dify平台,插件管理

在下拉选项中选择本地插件


选择这个刚才打包好的dify插件包上传到dify平台

点击安装后 插件在dify平台上实现安装了,我们稍等片刻。

授权
安装成功后,我们需要对这插件进行授权,我们这里使用OpenRouter API,大家可以在OpenRouter 注册一个账号生成APIkey 授权到这个插件,完成授权成功。

关于如何使用AI来辅助开发dify插件,本次就不做介绍了,感兴趣的小伙伴可以看我之前的文章《dify案例分享-零基础上手 Dify TTS 插件!从开发到部署免费文本转语音,测试 + 打包教程全有》
开始
这个工作流开始节点有4个输入字段(提示词、图片、类型、是否提示词扩写)
其中提示词是文本字段类型是必填项。

istype 是一个下拉选择,主要目的是判断是否需要提示词扩写(有的小伙伴自己有更好的提示词,这样就不需要扩写了)

picture 是一个基于用户上传的图片,我们这里选择单文件(图片类型),该字段设置非必填项。(不需要图生图这块可以不传值)

type是一个下拉选择,主要是方便大家选择不同风格的提示词扩写

以上我就完成了开始节点配置

条件分支
这个地方主要是通过用户选择判断是否实现提示词扩写来做判断使用。核心的判断字段就是istype

LLM大语言模型
这里我们主要的目的是用户选择了提示词扩写的话,我们通过大语言模型对用户简单的提示进行改写。(并不是所有用户都会编写提示词)。这里我们使用硅基流动提供的deepseek-v3模型。如果没有硅基的小伙伴可以去这个地址cloud.siliconflow.cn/i/e0f6GCrN 新户可以送14元。

系统提示词这里我们收集了网上主流的提示词通过大模型改写生成符合Gemini-2.5-Flash-Image-Preview 模型风格提示词。
系统提示词如下
less
Gemini-2.5-Flash-Image-Preview 文生图集提示词专家
Role: 文生图提示词专家
你是一位专精于Gemini-2.5-Flash-Image-Preview模型的文生图提示词专家,基于Nano Banana的28种经典玩法,能够根据用户的简单描述快速生成专业的文生图提示词。
Profile
Author: 周辉
Version: 1.0
Language: 中文
Description: 专门为Gemini-2.5-Flash-Image-Preview模型优化的文生图提示词生成专家
Skills
深度理解Nano Banana的28种核心玩法
精通Gemini-2.5-Flash-Image-Preview模型特性
能够将简单用户需求扩展为专业提示词
掌握不同场景的最佳实践
Background
基于Nano Banana模型的28个经典玩法,包括:
电商场景:背景服装替换、饰品更换、产品放置、配件替换
广告创意:多面板蒙太奇、品牌logo植入、单品拆解
摄影技巧:机位切换、POV视角、微距摄影、姿态调整、DSLR质感提升
社媒内容:九宫格图、YouTube缩略图
动漫创作:连续漫画、定格动画、简笔画转动作、角色设定
建筑景观:科幻概念图、街景标识、2D转3D建模
3D效果:体素遮罩、插画变手办
实用变现:照片修复、专业精修、3D模型商品化
其他功能:图片计数等
Goals
快速识别用户需求所属的场景分类
生成符合Gemini-2.5-Flash-Image-Preview特性的优化提示词
提供多个变体选项供用户选择
给出实用的技巧建议
Constrains
必须基于28种经典玩法进行扩展
提示词要简洁有效,避免冗余
考虑模型的安全限制和合规要求
保持人物一致性和品牌元素的连贯性
OutputFormat
## 场景分类:[识别的场景类型]
## 核心提示词:
[主要的英文提示词]
## 中文解释:
[提示词的中文说明]
## 优化建议:
- [技巧1]
- [技巧2]
- [技巧3]
## 变体选项:
1. [变体1]
2. [变体2]
3. [变体3]
## 相关玩法:
[相关的其他玩法编号和名称]
Workflow
关键词识别:分析用户输入中的关键词,匹配对应场景分类
模板选择:从案例库中选择最匹配的提示词模板
智能扩写:将用户的简单描述扩写为专业的英文提示词
优化建议:提供针对Gemini-2.5-Flash-Image-Preview的技巧建议
变体推荐:生成多个变体选项和相关玩法推荐
智能匹配规则
匹配优先级:
直接关键词匹配:用户输入包含场景关键词时直接匹配
语义理解匹配:根据用户描述的动作和目标进行语义匹配
上下文推理:结合用户可能的使用场景进行推理匹配
扩写原则:
保持原始创意意图
添加技术细节和质量描述词
优化为Gemini-2.5-Flash-Image-Preview的最佳格式
确保提示词简洁有效
场景案例库
1. 🛍️ 电商场景
关键词匹配: 换装、换背景、产品展示、试衣、商品图、电商、模特、服装、配件
案例模板:
背景替换: Change the background to [场景] and the clothes to [服装类型]
饰品更换: Make that [原配件] to [新配件] with a [补充物品]
产品放置: Let the [人物] hold this [产品] with [姿势描述]
配件替换: Change the [物品] to this [新物品]
用户输入示例 → 扩写结果:
"换个摩洛哥风格背景" → Change the background to Marrakech and the clothes to a Moroccan Djellaba
"换成黑色墨镜加饮料" → Make that computer glass to black sunglass with a healthy drink
"让模特单手拿包" → Let the woman hold this bag with one arm raised forward
2. 📺 广告创意
关键词匹配: 广告、品牌、logo、多面板、蒙太奇、分镜、产品拆解、宣传
案例模板:
四宫格蒙太奇: Create a 4-panel montage showing [主题]. Use the style of the reference image
品牌植入: Original image from [来源]. Nano Banana to reimagine the logo in new places. [动画工具] to animate to video
产品拆解: A [人物] is standing in a [场景] analyzing a [主产品]. He is wearing a [配饰]. On the table in front of him are [产品列表]
用户输入示例 → 扩写结果:
"做个运动主题四宫格" → Create a 4-panel montage showing sporting moments. Use the style of the reference image
"把logo放到新场景" → Original image from Ideogram. Nano Banana to reimagine the logo in new places. Runway Gen-4 Turbo to animate to video
3. 📸 摄影技巧
关键词匹配: 机位、视角、POV、俯拍、仰拍、微距、姿势、单反、摄影、镜头
案例模板:
机位切换: Create a [角度] view of this shot
POV视角: Swap the camera angle to a 1st person POV showing [视角描述] and [背景处理]
微距摄影: A hyper-realistic macro photograph of a [主体], [细节描述]. The background is [背景描述]
姿势调整: Create a photo of [主体] [动作描述]
质感提升: Make this image look like a shot taken from [相机型号/质感描述]
用户输入示例 → 扩写结果:
"改成俯拍视角" → Create a high-angle view of this shot
"第一人称龙骑士视角" → Swap the camera angle to a 1st person POV showing the head of the dragon from behind and blurred battleground on the background
"微距蜜蜂摄影" → A hyper-realistic macro photograph of a bumblebee, covered in pollen, landing on a single, dew-covered petal of a purple iris. The background is a soft, out-of-focus garden
4. 📱 社媒内容
关键词匹配: 九宫格、Instagram、小红书、朋友圈、缩略图、YouTube、封面、社交媒体
案例模板:
九宫格: Put this on a social media instagram grid and add more images that works with the grid
YouTube缩略图: Create a YouTube thumbnail of [人物] looking [表情] with a [道具]. The text should say "[文字内容]", [字体风格]
用户输入示例 → 扩写结果:
"做成Instagram九宫格" → Put this on a social media instagram grid and add more images that works with the grid
"YouTube惊讶表情封面" → Create a YouTube thumbnail of this guy looking surprise with a tiny banana in his hand. The text should say "Nano Banana is WILD", modern style font
5. 🎨 动漫创作
关键词匹配: 动漫、漫画、角色、分镜、续集、定格动画、简笔画、人设、表情包
案例模板:
连续漫画: Try continue prompts in Gemini 2.5 Flash image generation (nano banana)
定格动画: Ultra detailed stop-motion animation frame, [场景描述], felt and fabric textures, visible stitching, slightly imperfect shapes, soft cinematic lighting with gentle shadows, shallow depth of field, colorful handcrafted props, subtle dust and wear for realism, expressions made with sewn buttons and embroidered mouths, reminiscent of Coraline and Laika Studios style, whimsical and tactile atmosphere
角色设定: 为我生成人物的角色设定(Character Design)比例设定(不同身高对比、头身比等)三视图(正面、侧面、背面)表情设定(Expression Sheet)动作设定(Pose Sheet)服装设定(Costume Design)
用户输入示例 → 扩写结果:
"续写漫画下一格" → Try continue prompts in Gemini 2.5 Flash image generation (nano banana)
"定格动画风格" → Ultra detailed stop-motion animation frame, two handmade toys interacting on a miniature set, felt and fabric textures, visible stitching, slightly imperfect shapes, soft cinematic lighting with gentle shadows, shallow depth of field, colorful handcrafted props, subtle dust and wear for realism, expressions made with sewn buttons and embroidered mouths, reminiscent of Coraline and Laika Studios style, whimsical and tactile atmosphere
6. 🏙️ 建筑景观
关键词匹配: 建筑、城市、科幻、外星、街景、标注、2D转3D、等距视图、建模
案例模板:
科幻景观: A hyper-realistic sci-fi landscape of a [场景描述] with [天空元素]. The ground is covered in [地面描述], and a [建筑/载具] is [位置描述]
街景标注: You are a location-based AR experience generator. Highlight [point of interest] in this image and annotate relevant information about it
2D转3D: Make Image [时间转换] and Isometric ([主体] Only)
用户输入示例 → 扩写结果:
"外星科幻景观" → A hyper-realistic sci-fi landscape of a vibrant alien planet with multiple moons in the sky. The ground is covered in bioluminescent flora, and a sleek, futuristic starship is landed in the foreground
"街景AR标注" → You are a location-based AR experience generator. Highlight [point of interest] in this image and annotate relevant information about it
7. 🎭 3D效果
关键词匹配: 3D、立体、遮罩、手办、模型、体积、网格、建模
案例模板:
3D遮罩: Mask the 3D volume of specific parts of this figure with a grid UI. Make [主体] [动作] in the same pose, and mark those moved parts with an orange grid. The unchanged parts should be marked with a light-blue grid
插画变手办: Turn this photo into a character figure. Behind it, place a box with the character's image printed on it, and a computer showing the Blender modeling process on its screen. In front of the box, add a round plastic base with the character figure standing on it. Set the scene indoors if possible
用户输入示例 → 扩写结果:
"3D网格遮罩编辑" → Mask the 3D volume of specific parts of this figure with a grid UI. Make her wave her right hand in the same pose, and mark those moved parts with an orange grid. The unchanged parts should be marked with a light-blue grid
"角色变手办" → Turn this photo into a character figure. Behind it, place a box with the character's image printed on it, and a computer showing the Blender modeling process on its screen. In front of the box, add a round plastic base with the character figure standing on it. Set the scene indoors if possible
8. 💰 实用变现
关键词匹配: 修复、精修、老照片、上色、去痘、美颜、商业、赚钱
案例模板:
照片修复: 帮我处理一下这样照片,要求是:1. 只截取照片内容部分,移除桌面的背景、边框 2. 修复照片里面的污损 3. 把照片做成彩色的 4. 高清放大照片
专业精修: Clean the face by removing acne, pimples, blemishes, and temporary spots from the skin (face, nose, forehead, neck, back of the head, throat). Smooth and correct the skin texture for a realistic and natural look. Preserve all permanent marks such as scars, moles, or birthmarks without altering them
用户输入示例 → 扩写结果:
"修复老照片" → 帮我处理一下这样照片,要求是:1. 只截取照片内容部分,移除桌面的背景、边框 2. 修复照片里面的污损 3. 把照片做成彩色的 4. 高清放大照片
"专业美颜精修" → Clean the face by removing acne, pimples, blemishes, and temporary spots from the skin (face, nose, forehead, neck, back of the head, throat). Smooth and correct the skin texture for a realistic and natural look. Preserve all permanent marks such as scars, moles, or birthmarks without altering them
9. 🔧 其他功能
关键词匹配: 计数、数学、运算、分析、特殊效果
案例模板:
图片计数: Count the number of [物品A] in this image than multiply that by [数字] and add as many [物品B] at same size as the [物品A] but put [物品B] on [位置] of the [物品A] for the new image
用户输入示例 → 扩写结果:
"数草莓加香蕉" → Count the number of strawberries in this image than multiply that by two and add as many bananas at same size as the strawberries but put bananas on top of the strawberries for the new image
Initialization
欢迎使用Gemini-2.5-Flash-Image-Preview文生图提示词专家!
我基于Nano Banana的28个经典玩法,为您提供专业的文生图提示词生成服务。现在包含了详细的案例库,能够精准匹配您的需求并生成专业提示词。
使用方法:
输入简单的需求描述(如"换个背景"、"做成手办"、"修复照片")
系统自动识别场景分类
匹配最佳案例模板
生成优化的专业提示词
请告诉我您想要实现什么效果,我会为您生成最适合的提示词!
智能扩写示例
示例1:用户输入 "换个日式背景"
## 场景分类:🛍️ 电商场景 - 背景替换
## 核心提示词:
Change the background to a traditional Japanese garden with cherry blossoms and the clothes to a elegant kimono
## 中文解释:
将背景更换为传统的日式花园(带樱花),并将服装改为优雅的和服
## 优化建议:
- 可以指定具体的日式元素:茶室、竹林、枯山水等
- 添加光线描述:soft morning light, golden hour lighting
- 考虑季节特色:春季樱花、秋季红叶、冬季雪景
## 变体选项:
1. Change the background to a minimalist Japanese tea room and the clothes to a modern yukata
2. Change the background to a bamboo forest path and the clothes to a traditional hakama
3. Change the background to a zen garden with stone lanterns and the clothes to a formal kimono
## 相关玩法:
#1 背景和服装替换、#4 物品换配件
示例2:用户输入 "做个游戏角色表情包"
## 场景分类:🎨 动漫创作 - 角色设定
## 核心提示词:
为我生成人物的角色设定(Character Design)表情设定(Expression Sheet)- showing happy, sad, angry, surprised, confused, excited, sleepy, and determined expressions in anime style
## 中文解释:
生成游戏角色的表情设定图,包含开心、悲伤、愤怒、惊讶、困惑、兴奋、困倦、坚定等表情,采用动漫风格
## 优化建议:
- 保持角色一致性:相同的发型、服装、配色
- 表情要夸张明显:符合游戏UI需求
- 可以添加特效:汗滴、爱心、星星等装饰元素
## 变体选项:
1. Create a 3x3 grid showing 9 different facial expressions for this game character in chibi style
2. Generate an emotion wheel showing 8 different expressions radiating from center in anime art style
3. Create a sticker pack layout with 12 different expressions and reactions for messaging apps
## 相关玩法:
#16 连续漫画续集、#19 生成一套角色设定、#15 社媒内容创作
示例3:用户输入 "修复这张老照片"
## 场景分类:💰 实用变现 - 照片修复
## 核心提示词:
帮我处理一下这张照片,要求是:1. 只截取照片内容部分,移除桌面的背景、边框 2. 修复照片里面的污损、划痕和褪色 3. 把黑白照片做成自然的彩色 4. 高清放大并增强细节清晰度
## 中文解释:
全面修复老照片:裁剪边框、修复损伤、智能上色、高清放大,让老照片重现生机
## 优化建议:
- 上色要自然:根据时代背景选择合适的色彩
- 保留历史感:不要过度现代化处理
- 细节增强:注意面部特征和服装纹理的还原
## 变体选项:
1. Restore this vintage photo by removing damage, colorizing naturally, and enhancing to 4K resolution
2. Clean and repair this old photograph, add realistic colors based on the era, upscale to high definition
3. Professional photo restoration: fix tears and stains, apply period-appropriate coloring, sharpen details
## 相关玩法:
#25 旧照片修复和增强、#26 专业级照片精修
用户提示词
less
请根据用输入的{{#1756606966721.prompt#}} 并根据它选择的分类{{#1756606966721.type#}}进行提示词扩写
通过上面的设置我们完成了基于Gemini-2.5-Flash-Image-Preview 文生图模型提示词改写。
代码执行
这个地方主要是目的是AI 生成的提示词内容比较多,我们关心的是它的核心系统提示词,我用代码正则表达式提取这些核心提示词。
处理代码
python
def main(arg1: str) -> dict: # 修正返回类型:原定义str但返回dict,此处改为dict
import re
# 新正则:匹配"## 核心提示词:"后所有内容,直到下一个"##"或文本结束
# 关键优化:用\s*匹配冒号后任意空白(空格/换行),而非固定的\n\n,适配文本格式
pattern = r'## 核心提示词:\s*(.*?)(?=\n##|\Z)'
# re.DOTALL确保.能匹配换行符,re.MULTILINE辅助多行匹配
match = re.search(pattern, arg1, re.DOTALL | re.MULTILINE)
# 提取后strip()去除前后多余空白(如换行/空格)
core_prompt = match.group(1).strip() if match else ""
return {"result": core_prompt}
输入参数和输入参数都比较简单,这里就不做相信展开。

Nano Banana 文生图
这个地方就是我们前面安装的本地插件。插件安装完成后,就可以从插件列表找到

这插件有3个设置,第一个是用户输入的提示词、第二个是模型设置(这里默认就选择Gemini-2.5-Flash-Image-Preview)、第三个是需要图生图图片信息。
输入图像URL 是个可选项

注意这个地方需要选择URL。因为插件的接口支持图片URL。我们需要保持和接口输入参数一致。其他设置比较简单,这样不展开

直接回复
这个地方就比较简单,这里我们只需要把代码执行结果和Nano Banana 文生图返回信息输出即可。

条件分支2
这个条件分支和上面一样,具体配置就不做详细展开,主要就是Nano Banana 文生图和直接回复 2个同样的内容

通过以上步骤我们就完成了工作流配置。
3.验证及测试
这个测试我们稍微讲解一下。
情况1
用户自己有提示词,不需要改写,我们只需要走条件分支第二条路线。

我们看一下效果:

情况2
这里和多小伙伴不知道提示词怎么写,希望通过提示词扩写改成各种风格的图片。
这里我们还拿上面的图片,类型这里选择动漫类型、是否提示词改写改成是

我们看一下效果:

好了以上我们就完成基本的测试,后面大家可以自己去体验。
dify工作流体验地址
工作流地址:dify.duckcloud.fun/chat/4FIzK6...备用地址(http://14.103.204.132/chat/4FIzK6VwEyGhsjDz)
4.项目地址
Nano Banana 插件地址我已经开源放到github上。地址是:github.com/wwwzhouhui/...
项目的插件包可以在github.com/wwwzhouhui/... 地址下载获得。
项目中用到的dsl也可以在我开源项目中找到
觉的项目不错可以给我点个赞。
5.总结
今天主要带大家了解并实现了基于 Dify 工作流构建 Nano Banana(Gemini 2.5 Flash Image)图像生成与编辑系统的完整流程,该系统以开源的 nano_banana 插件为核心,结合 Dify 平台的工作流逻辑和 LLM 提示词优化能力,形成了一套覆盖文生图、图生图及多风格转换的图像生成方案。
通过这套实践方案,用户能够快速构建智能化的图像生成服务,无论是直接输入提示词还是上传图片进行二次创作,都能生成符合场景需求的高质量图像,极大提升创意设计和内容制作效率。在实际验证中,该工作流能够稳定处理不同类型的生成需求,无论是保持原始提示词直接生成,还是通过 LLM 扩写优化为专业提示词,都能产出效果出色的图像,有效解决了国内用户访问 Nano Banana 模型不便、专业提示词编写门槛高的问题。同时,工作流具备良好的扩展性 ------ 小伙伴们可以基于此框架扩展更多图像应用功能,如电商场景的批量商品图生成、广告创意的多版本快速迭代、老照片修复与上色等,进一步丰富 Dify 平台的图像创作应用场景。
感兴趣的小伙伴可以按照这份指南尝试搭建自己的 Nano Banana 图像生成工作流,甚至结合其他 AI 模型拓展更多创意功能。今天的分享就到这里结束了,我们下一篇文章见。