什么是Nano Banana?示例实战梳理
神马中转API
国内直连企业级中转,600+全模型支持
Google 在 Gemini API 里提供了一套原生图片生成/编辑能力,这条能力线称为 Nano Banana:你可以只用文字生成图片,也可以把“文字 + 图片”一起喂给模型,让它对图片进行修改、风格迁移、内容增删,甚至在同一段对话里不断迭代同一张图,做到“边聊边改图”的工作流。
注意:所有生成的图片都会带 SynthID 水印(用于标识 AI 生成内容)。
两种 Nano Banana 模型:一个追求速度,一个追求“专业级可控”
Nano Banana 对应到 Gemini API 的两类模型:
-
Gemini 2.5 Flash Image(
gemini-2.5-flash-image)
面向速度与效率,适合高并发、低延迟、批量出图场景;输出分辨率以 1024 级别为主。 -
Gemini 3 Pro Image 预览版(
gemini-3-pro-image-preview)
面向专业素材制作,强调复杂指令跟随与高保真文字渲染,并且能上 2K/4K;还支持用 Google Search 做“接地/事实校验”,并带“思考模式”来优化构图。
最基础的能力:文字生成图片(Text-to-Image)
示例(Python/JS/Go/Java/REST),核心思路是一致的:调用 generateContent,并把 responseModalities 设为包含 IMAGE,模型返回的内容里会出现文本 part和图片二进制(inline_data)part,你把图片 part 写入文件即可。
示例:
from google import genai
from google.genai import types
from PIL import Image
client = genai.Client()
prompt = ("Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme")
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents=[prompt],
)
for part in response.parts:
if part.text is not None:
print(part.text)
elif part.inline_data is not None:
image = part.as_image()
image.save("generated_image.png")
更常用的能力:上传图片 + 文字指令(Image Editing / Image-to-Image)
当你提供一张图片,再给一句清晰的编辑指令,模型就能做诸如:
-
添加/移除元素
-
改风格
-
调色与氛围
-
保持构图不变只改文字(非常适合海报/信息图多语言版本)
注意:上传图片前要确保你有必要权利,不要生成侵犯他人权利或用于欺骗、骚扰、伤害的内容,并需遵守使用限制政策。
“对话式改图”:同一张图多轮迭代(特别适合信息图/海报)
示例:
-
先生成一张“光合作用信息图”(儿童彩色食谱页面风格)
-
然后在同一对话里让模型把图中文字改成西班牙语,并要求其它元素都不变
图 1:
from google import genai
from google.genai import types
client = genai.Client()
chat = client.chats.create(
model="gemini-3-pro-image-preview",
config=types.GenerateContentConfig(
response_modalities=['TEXT', 'IMAGE'],
tools=[{"google_search": {}}]
)
)
message = "Create a vibrant infographic that explains photosynthesis as if it were a recipe for a plant's favorite food. Show the \"ingredients\" (sunlight, water, CO2) and the \"finished dish\" (sugar/energy). The style should be like a page from a colorful kids' cookbook, suitable for a 4th grader."
response = chat.send_message(message)
for part in response.parts:
if part.text is not None:
print(part.text)
elif image:= part.as_image():
image.save("photosynthesis.png")
关于光合作用的 AI 生成信息图
图 2:
message = "Update this infographic to be in Spanish. Do not change any other elements of the image."
aspect_ratio = "16:9" # "1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"
resolution = "2K" # "1K", "2K", "4K"
response = chat.send_message(message,
config=types.GenerateContentConfig(
image_config=types.ImageConfig(
aspect_ratio=aspect_ratio,
image_size=resolution
),
))
for part in response.parts:
if part.text is not None:
print(part.text)
elif image:= part.as_image():
image.save("photosynthesis_spanish.png")
同一张信息图被改成西班牙语版本

Gemini 3 Pro Image 的“专业增强点”到底强在哪?
-
高分辨率输出(1K/2K/4K)
-
高级文字渲染:更适合做菜单、图表、信息图、营销物料
-
Google Search 接地:可以调用搜索来核验事实、用实时数据做可视化(如天气图、股市图、近期活动)
-
思考模式:会先在后端生成临时“思维图像”辅助推理与构图
-
最多 14 张参考图:可混合多张对象图/人物图来保持一致性
最多可使用 14 张参考图片
最多可以混合使用 14 张参考图片。这 14 张图片可以包含以下内容:
- 最多 6 张高保真对象图片,用于包含在最终图片中
- 最多 5 张人物图片,以保持角色一致性
让图片“有依据”:用 Google Search 生成带事实支撑的视觉
让模型把“旧金山未来 5 天天气 + 穿衣建议”做成一张干净现代的天气图表,并说明响应里会包含 groundingMetadata,例如:
-
searchEntryPoint:用于展示搜索建议的 HTML/CSS -
groundingChunks:用于支撑生成结果的前 3 个网络来源
示例:旧金山五天天气可视化图表
from google import genai
prompt = "Visualize the current weather forecast for the next 5 days in San Francisco as a clean, modern weather chart. Add a visual on what I should wear each day"
aspect_ratio = "16:9" # "1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"
client = genai.Client()
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=prompt,
config=types.GenerateContentConfig(
response_modalities=['Text', 'Image'],
image_config=types.ImageConfig(
aspect_ratio=aspect_ratio,
),
tools=[{"google_search": {}}]
)
)
for part in response.parts:
if part.text is not None:
print(part.text)
elif image:= part.as_image():
image.save("weather.png")

生成分辨率高达 4K 的图片
Gemini 3 Pro Image 默认生成 1K 图片,但也可以输出 2K 和 4K 图片。如需生成更高分辨率的资源,请在 generation_config 中指定 image_size。
您必须使用大写“K”(例如,1K、2K、4K)。小写参数(例如,1k)将被拒绝。
思维过程
Gemini 3 Pro Image 预览版模型是一种思考模型,会使用推理流程(“思考”)来处理复杂的提示。此功能默认处于启用状态,并且无法在 API 中停用。如需详细了解思考过程,请参阅 Gemini 思考指南。
模型最多会生成两张临时图片,以测试构图和逻辑。“思考”中的最后一张图片也是最终渲染的图片。
您可以查看促成最终图片生成的想法。
其他图片生成模式
Gemini 还支持其他基于提示结构和上下文的图片互动模式,包括:
- 文生图和文本(交织):输出包含相关文本的图片。
- 提示示例:“生成一份图文并茂的海鲜饭食谱。”
- 图片和文本转图片和文本(交织):使用输入图片和文本创建新的相关图片和文本。
- 提示示例:(附带一张带家具的房间的照片)“我的空间还适合放置哪些颜色的沙发?你能更新一下图片吗?”
提示指南和策略
要掌握图片生成,首先要了解一个基本原则:
描述场景,而不仅仅是列出关键字。 该模型的核心优势在于其深厚的语言理解能力。与一连串不相关的字词相比,叙述性描述段落几乎总是能生成更好、更连贯的图片。
用于生成图片的提示
以下策略将帮助您创建有效的提示,从而生成您想要的图片。
1. 逼真场景
对于逼真的图片,请使用摄影术语。提及拍摄角度、镜头类型、光线和细节,引导模型生成逼真的效果。

A photorealistic close-up portrait of an elderly Japanese ceramicist with
deep, sun-etched wrinkles and a warm, knowing smile. He is carefully
inspecting a freshly glazed tea bowl. The setting is his rustic,
sun-drenched workshop. The scene is illuminated by soft, golden hour light
streaming through a window, highlighting the fine texture of the clay.
Captured with an 85mm portrait lens, resulting in a soft, blurred background
(bokeh). The overall mood is serene and masterful. Vertical portrait
orientation.
2. 风格化插画和贴纸
如需创建贴纸、图标或素材资源,请明确说明样式并要求使用透明背景。

A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's
munching on a green bamboo leaf. The design features bold, clean outlines,
simple cel-shading, and a vibrant color palette. The background must be white.
3.图片中的文字准确无误
Gemini 在呈现文本方面表现出色。清楚说明文字、字体样式(描述性)和整体设计。使用 Gemini 3 Pro Image 预览版制作专业资源。

Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'. The text should be in a clean, bold, sans-serif font. The color scheme is black and white. Put the logo in a circle. Use a coffee bean in a clever way.
4.产品模型和商业摄影
非常适合为电子商务、广告或品牌宣传制作清晰专业的商品照片。

A high-resolution, studio-lit product photograph of a minimalist ceramic
coffee mug in matte black, presented on a polished concrete surface. The
lighting is a three-point softbox setup designed to create soft, diffused
highlights and eliminate harsh shadows. The camera angle is a slightly
elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with
sharp focus on the steam rising from the coffee. Square image.
5.连续艺术(漫画分格 / 故事板)
以角色一致性和场景描述为基础,创建用于视觉叙事的面板。为了确保文本准确性和故事讲述能力,这些提示最适合搭配 Gemini 3 Pro Image 预览版使用。

Make a 3 panel comic in a gritty, noir art style with high-contrast black and white inks. Put the character in a humurous scene.
用于修改图片的提示
以下示例展示了如何提供图片以及文本提示,以进行编辑、构图和风格迁移。
1. 添加和移除元素
提供图片并描述您的更改。模型将与原始图片的风格、光照和透视效果保持一致。

"Using the provided image of my cat, please add a small, knitted wizard hat
on its head. Make it look like it's sitting comfortably and matches the soft
lighting of the photo."
2. 局部重绘(语义遮盖)
通过对话定义“蒙版”,以修改图片的特定部分,同时保持其余部分不变。

"Using the provided image of a living room, change only the blue sofa to be
a vintage, brown leather chesterfield sofa. Keep the rest of the room,
including the pillows on the sofa and the lighting, unchanged."
3. 风格迁移
提供一张图片,并让模型以不同的艺术风格重新创作其内容。

"Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows."
4. 高级合成:组合多张图片
提供多张图片作为上下文,以创建新的合成场景。这非常适合制作产品模型或创意拼贴画。

"Create a professional e-commerce fashion photo. Take the blue floral dress
from the first image and let the woman from the second image wear it.
Generate a realistic, full-body shot of the woman wearing the dress, with
the lighting and shadows adjusted to match the outdoor environment."
5. 高保真细节保留
为确保在修改过程中保留关键细节(例如面部或徽标),请在修改请求中详细描述这些细节。

"Take the first image of the woman with brown hair, blue eyes, and a neutral
expression. Add the logo from the second image onto her black t-shirt.
Ensure the woman's face and features remain completely unchanged. The logo
should look like it's naturally printed on the fabric, following the folds
of the shirt."
6. 让事物焕发活力
上传草图或简笔画,然后让模型将其优化为成品图片。

"Turn this rough pencil sketch of a futuristic car into a polished photo of the finished concept car in a showroom. Keep the sleek lines and low profile from the sketch but add metallic blue paint and neon rim lighting."
7. 字符一致性:360 度全景
您可以迭代提示不同的角度,从而生成角色的 360 度视图。为获得最佳效果,请在后续提示中添加之前生成的图片,以保持一致性。对于复杂的姿势,请添加所需姿势的参考图片。

A studio portrait of this man against white, in profile looking right
最佳做法
如需将搜索结果从“好”提升到“出色”,请将以下专业策略融入您的工作流程。
- 具体化:您提供的信息越详细,对输出结果的掌控程度就越高。与其使用“奇幻盔甲”,不如具体描述:“华丽的精灵板甲,蚀刻着银叶图案,带有高领和猎鹰翅膀形状的肩甲。”
- 提供上下文和意图:说明图片的用途。模型对上下文的理解会影响最终输出。例如,“为高端极简护肤品牌设计徽标”的效果要好于“设计徽标”。
- 迭代和优化:不要指望第一次尝试就能生成完美的图片。利用模型的对话特性进行小幅更改。使用后续提示,例如“这很棒,但你能让光线更暖一些吗?”或“保持所有内容不变,但让角色的表情更严肃一些。”
- 使用分步指令:对于包含许多元素的复杂场景,请将提示拆分为多个步骤。“首先,创建一个宁静、薄雾弥漫的黎明森林的背景。然后,在前景中添加一个长满苔藓的古老石制祭坛。最后,将一把发光的剑放在祭坛顶部。”
- 使用“语义负面提示”:不要说“没有汽车”,而是通过说“一条没有交通迹象的空旷、荒凉的街道”来正面描述所需的场景。
- 控制镜头:使用摄影和电影语言来控制构图。例如
wide-angle shot、macro shot、low-angle perspective等字词。
限制
- 为获得最佳性能,请使用以下语言:英语、阿拉伯语(埃及)、德语(德国)、西班牙语(墨西哥)、法语(法国)、印地语(印度)、印度尼西亚语(印度尼西亚)、意大利语(意大利)、日语(日本)、韩语(韩国)、葡萄牙语(巴西)、俄语(俄罗斯)、乌克兰语(乌克兰)、越南语(越南)、中文(中国)。
- 图片生成不支持音频或视频输入。
- 模型不一定会严格按照用户明确要求的图片输出数量来生成图片。
gemini-2.5-flash-image最多可接受 3 张图片作为输入,而gemini-3-pro-image-preview最多可接受 14 张图片,其中 5 张图片可实现高保真度。- 为图片生成文字时,最好先生成文字,然后再要求生成包含该文字的图片,这样 Gemini 的效果最好。
- 所有生成的图片都包含 SynthID 水印。
模型怎么选:Flash、Pro,还是直接用 Imagen?
-
复杂指令、专业素材、需要接地搜索、需要 2K/4K → 优先 Gemini 3 Pro Image 预览版
-
高吞吐、低延迟、批量出图 → Gemini 2.5 Flash Image
-
另外,如果你想用“专门的图片生成模型”,推荐选择用AIHub API。
用AIHub智慧代理API,把「用 AI」这件事变简单
一次接入,多模型自由切换
AIHub智慧代理API提供统一的 API 接口,将多种全球600+主流大模型能力整合在一起。
无需为不同模型反复适配,只需一次接入,就能按需灵活调用。
这意味着:
-
模型升级不再是重构工程
-
可以根据场景快速切换最合适的模型
-
产品对上层业务几乎“无感升级”
核心卖点一眼看懂:
-
✅ 统一 API 接口:一次接入,多模型灵活调用
-
✅ 更高稳定性:智能代理与调度,减少异常与波动
-
✅ 开发成本低:接入简单,文档清晰,几乎零学习负担
-
✅ 模型可随时升级:业务无感知,不怕模型变化
-
✅ 成本可控:适合测试、上线、长期运行的 AI 应用
如果你不想再为模型切换、接口不稳定、维护复杂而反复返工,
那你需要的,可能不是“更强的模型”,而是一个更聪明的 AI 接入方式。
用 AIHub 智慧代理 API,把「用 AI」这件事变简单
这两年,AI 能力的提升有目共睹,但真正把 AI 稳定、高效、低成本地用到产品里,很多团队都会遇到同一个问题:
接口不稳定、模型切换麻烦、调用成本不可控、接入复杂……
如果你也在为这些问题头疼,AIHub 智慧代理 API(aihubproxy.com),或许正是你在找的解决方案。

