提示词指南

Nano Banana 提示词指南:生图、改图与图中文字

为 Nano Banana Pro 和 2.1 准备的 9 条提示词:场景生成、参考图修改、多参考图合成、图中文字精确输出,并附可直接运行的 API 调用。

一支香蕉形状的画笔,正在画架上的画布上描绘发光的风景
文档目录

Nano Banana Pro 和 Nano Banana 2.1 接收一段自然语言提示词(可以附带参考图),返回一张图片。本文按用途整理了 9 条提示词:场景生成、修改已有图片、多参考图合成、图中文字精确输出。每条都说明了为什么这样写;另附一个简短的 Python 辅助函数,用来通过 DreamTo API 跑这些提示词。

Nano Banana Pro(gemini-3-pro-image)和 Nano Banana 2.1(gemini-nano-banana-2.1)的请求格式相同,所以 9 条提示词里有 8 条不用改就能在两个模型上运行。提示词 6 用到了风格参考图,而文档里只写了 Pro 支持这一项。

先把请求配置好#

两个模型都走 https://api.dreamto.ai 上的 generateContent 接口。密钥放在 Authorization: Bearer 请求头里,也可以放在 x-goog-api-key 里。请求是同步的,通常需要 5 到 60 秒。下面是一个能跑通的最小调用:

bash
curl -X POST "https://api.dreamto.ai/v1beta/models/gemini-nano-banana-2.1:generateContent" \  -H "Authorization: Bearer $DREAMTO_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "contents": [      {        "role": "user",        "parts": [          { "text": "A ceramic mug of black coffee on a windowsill, rain outside, soft morning light" }        ]      }    ],    "generationConfig": {      "responseModalities": ["TEXT", "IMAGE"],      "imageConfig": { "aspectRatio": "16:9", "imageSize": "2K" }    }  }'

调试提示词时会用到下面这些字段:

字段取值
contents[].parts[].text提示词:要生成或修改什么
contents[].parts[].inlineData.dataBase64 编码的参考图,mimeType 可为 image/png、image/jpeg、image/webp、image/heic 或 image/heif
contents[].parts[].fileData.fileUri以公开 https 链接提供的参考图
generationConfig.imageConfig.aspectRatioPro:1:1、2:3、3:2、3:4、4:3、4:5、5:4、9:16、16:9、21:9。2.1 另外支持 1:4、4:1、1:8、8:1。不填时:文生图默认 1:1,改图沿用输入图的比例
generationConfig.imageConfig.imageSize1K(默认)、2K 或 4K,K 必须大写
generationConfig.responseModalities["TEXT", "IMAGE"](默认),或只返回图片的 ["IMAGE"]

下面的辅助函数封装了这次调用:可以附带任意数量的本地参考图,并把结果写到磁盘上。它只要图片,而且只有你传了 aspectRatio 才会发送这个字段,所以改图时会沿用输入图的比例。后面的示例都假定它保存为 gen.py。

python
import base64import mimetypesimport osimport requestsMODEL = os.environ.get("MODEL", "gemini-nano-banana-2.1")URL = f"https://api.dreamto.ai/v1beta/models/{MODEL}:generateContent"HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}def generate(prompt, refs=(), aspect_ratio=None, size="1K", out="output.png"):    parts = [{"text": prompt}]    for path in refs:        mime = mimetypes.guess_type(path)[0] or "image/png"        with open(path, "rb") as f:            data = base64.b64encode(f.read()).decode()        parts.append({"inlineData": {"mimeType": mime, "data": data}})    image_config = {"imageSize": size}    if aspect_ratio:        image_config["aspectRatio"] = aspect_ratio    payload = {        "contents": [{"role": "user", "parts": parts}],        "generationConfig": {            "responseModalities": ["IMAGE"],            "imageConfig": image_config,        },    }    resp = requests.post(URL, headers=HEADERS, json=payload, timeout=300)    resp.raise_for_status()    candidate = resp.json()["candidates"][0]    for part in candidate["content"]["parts"]:        if "inlineData" in part and not part.get("thought"):            with open(out, "wb") as f:                f.write(base64.b64decode(part["inlineData"]["data"]))            return out    raise RuntimeError(f"no image in response: {candidate.get('finishReason')}")

设置环境变量 MODEL=gemini-3-pro-image,就会改用 Pro。无效请求和生成失败的请求不会计费,错误码见错误说明。

场景提示词:描述一张照片,而不是堆标签#

场景提示词写成对一张照片的简短描述即可:主体、所在位置、光线、镜头或媒介,以及哪些东西不要出现。Pro 的模型页还给了一个建议:先从设计规格写起,也就是目标宽高比、视觉重点、需要留白的位置和确切的文案。

提示词 1:有视角的实景#

text
Architectural photograph of a small timber ferry terminal at dusk on a calm grey bay.Shot from the water at eye level, 35mm lens, the terminal's windows lit warm amberagainst a blue-grey sky. A single figure with a red umbrella stands at the end of thepier. Empty foreground, no boats, no text.

机位、镜头加上一处强调色,模型就有了可以照着走的构图。结尾的“no boats, no text”点明了哪些杂物不要出现。

提示词 2:受控布景中的产品#

text
Studio product photograph of an unbranded matte-green glass bottle standing on aslab of pale travertine. Single soft window light from the left, a long gentleshadow to the right, seamless warm-white backdrop. Bottle centred, slightly belowthe middle of the frame, with generous empty space above. No label, no logos.

这条提示词同时安排了物体的位置和留白的位置,生成的图可以直接当横幅背景。如果之后要自己合成 logo,就在提示词里写明不要 logo。

提示词 3:宽画幅#

text
Panoramic illustration of a salt flat at first light, a lone cyclist crossing it,long thin clouds stretching to the horizon, flat gouache colours in peach andslate blue, paper grain. Wide empty sky in the upper half.

运行时把 aspectRatio 设为 21:9,两个模型都可以。Nano Banana 2.1 还支持 Pro 没有的 4:1 和 8:1,它的文档还给出了这两种比例在 2K 和 4K 下出现拼接伪影时的解决办法。

改图提示词:说清楚改什么、留什么#

改图时,把图片作为 inlineData 部分,或者以公开链接放进 fileData.fileUri,和文本部分一起发送。像给修图师交代活儿那样写:先说要改什么,再说哪些必须保持不变。

2.1 的模型页建议限定局部修改的范围:描述修改的区域和边缘,点名要保留的文字和轮廓,改完后再把修改区域之外的部分和原图对比一遍。

提示词 4:局部修改并列出保留项#

text
Using the attached photo, replace only the wall behind the sofa with deepbottle-green paint with a subtle matte texture. Keep the sofa, the cushions, thefloor lamp, the framed print and all shadows exactly as they are. Do not changethe camera angle or the lighting on the floor.

这条提示词只有一处修改、一个明确的区域,以及一份不许动的清单。要改两处就分成两次请求,每次都检查结果。

提示词 5:改变时间或天气#

text
Edit the attached street photo so it is a rainy evening. Wet pavement withreflections of the shop signs, the same buildings, the same people in the samepositions, headlights on the cars. Keep the framing identical.

提示词写的是成图的样子,不是操作步骤;它还写明了哪些内容保持不变,这样改出来的才不会是一张全新的图。

在定稿图上接着改#

先定稿一张图,再往下改。2.1 的模型页建议把定稿的原图、对应的提示词和文案放在一起保存,后面每次只记下改了什么,这样一组图之间出现了不该有的差异,一眼就能看出来。用代码实现时,把上一次的输出作为参考图传回去:

python
from gen import generategenerate(    "Create a product poster for the attached bottle on a pale travertine slab.",    refs=["bottle.jpg"],    aspect_ratio="4:5",    out="v1.png",)generate(    "Keep everything in the attached poster. Change only the background colour to "    "warm terracotta. Do not move the bottle.",    refs=["v1.png"],    aspect_ratio="4:5",    out="v2.png",)

API 也支持多轮 contents,把模型之前返回的部分原样发回即可。不过把定稿图当作参考图发一个新请求,脚本写起来更简单。

多参考图提示词:给每张图指定角色#

两个模型每次请求最多都可以带 14 张参考图,只是各类型的上限不同:

模型物体图角色图风格参考图
gemini-3-pro-image最多 6 张最多 5 张最多 3 张
gemini-nano-banana-2.1最多 10 张最多 4 张未列出

在提示词里给每张图指定角色。2.1 的模型页建议:主体用一张照片,构图用一张草图,颜色和光线另外用文字说明。这样结果哪里不对,就能找到是哪条指令造成的。

提示词 6:主体、布局和风格分开输入#

text
Three reference images are attached. Image 1 is the product: keep its shape,colours and proportions exactly. Image 2 is a rough layout sketch: follow itsplacement of the product and the empty area on the right. Image 3 is a stylereference: use only its colour palette and the softness of its light, not itssubject. Result: a clean advertising image in a 4:5 frame.

给参考图编号,并说明每张图取什么、不取什么。这一版是写给 Pro 的,因为文档里只有 Pro 支持风格参考图。在 2.1 上,只附图 1 和图 2,配色和光线改用文字描述,代替图 3。

提示词 7:同一角色出现在不同场景#

text
Using the attached character reference, show the same woman, same hairstyle andthe same yellow raincoat, sitting at a night-market noodle stall. Only the settingchanges: warm paper lanterns, steam, shallow depth of field. Keep her face andclothing details unchanged.

这条用的是 2.1 模型页关于一致性的建议:准备一张清晰的角色参考图,点明会变化的姿势或场景,并列出需要保留的细节。之后逐个场景对比发型、服装和色调。

需要风格参考图,或者想在一张图里放第五个角色时,选 Pro。2.1 能带更多物体图(10 张,Pro 是 6 张),每次请求的价格也更低。

图中文字提示词:文案加引号,写明位置#

模型目录说 Pro 是 Google 图中文字效果最好的模型,2.1 的文档则说它生成文字和信息图版式比上一代更准确。无论用哪个模型,都要把确切的文字用引号引起来,并说明每句话放在哪里、出现几次。

提示词 8:文案固定的海报#

text
Flat editorial poster, cream background with one large terracotta circle. Exactheading "SLOW SUNDAYS" in heavy black sans-serif capitals at the top. Small subhead"A MARKET FOR THE LONG MORNING" beneath it. Footer text at the bottom left:"OPEN 9 TO 2". Render each of those three phrases once, with exact spelling andgenerous margins. No other text, no logos.

引号、每句话的位置,再加上“once”这个词,模型就没什么自由发挥的余地了。结尾的“No other text”和文案本身一样重要。

提示词 9:带标注的示意图#

text
Clean infographic on a white background showing the water cycle with four labelledsteps in a clockwise loop: "Evaporation", "Condensation", "Precipitation","Collection". One simple arrow between each step, flat pastel icons, labels in asingle dark-grey sans-serif font, equal text size. No other words.

标签要短。模型页建议按交付尺寸检查拼写、换行和数字。法律声明或价格这类文字,最好自己排版,只让模型生成底下的画面。

做多语言版本时,Pro 的模型页建议每种语言都提供一条定稿的标题,每出一版都检查行数和最小可读字号。

选 Pro 还是 2.1#

除了提示词 6,这些提示词都不绑定模型,所以按参考图、宽高比和价格来选就行。

Nano Banana ProNano Banana 2.1
模型 IDgemini-3-pro-imagegemini-nano-banana-2.1
尺寸1K / 2K / 4K1K / 2K / 4K
宽高比10 种14 种,包括 1:4、4:1、1:8、8:1
参考图最多 14 张(6 张物体图、5 张角色图、3 张风格参考图)最多 14 张(10 张物体图、4 张角色图)
推理出图前先思考,始终开启,无法关闭默认中等思考级别
每次请求的价格(截至 2026 年 12 月)$0.03(1K)、$0.03(2K)、$0.05(4K)$0.01(1K)、$0.02(2K)、$0.03(4K)

按请求计费,只有 imageSize 会影响价格,最新价格见 /prices。按这个价格,2.1 出一张 1K 草图只要 2K 成图的一半、4K 成图的三分之一,所以先用 1K 定下构图和措辞,再用定稿的提示词按交付尺寸出图。Pro 的 1K 和 2K 价格相同。

2.1 的上一代 Nano Banana 2(gemini-3.1-flash-image)也可以用。写代码之前,可以先在 Nano Banana Pro 体验页或 Nano Banana 2.1 体验页里试这些提示词。

关于尺寸和参考图的更多细节,见 Nano Banana Pro API 使用指南和 Nano Banana 2.1、Pro、2、2 Lite 怎么选。商品图方面,AI 生图产品图提示词讲得更深入。

API 目前的限制#

  • 暂不支持 systemInstruction、safetySettings 和 tools(包括 Google 搜索增强)。带上它们会返回 400,不会调用模型,也不会计费。需要长期生效的指令,请直接写进提示词。
  • 只支持 generateContent。不支持 Batch API,也不支持通过 Files API 上传后得到的 files/... 引用;图片请用 Base64 或公开的 https 链接发送。
  • 上游生成失败(包括内容审核拒绝)会返回 502,不计费,可以重试。
  • 错误响应用的是 DreamTo 自己的错误结构,不是 Google 的 status 结构。密钥和请求头的说明见鉴权页面。

完整参数列表见 Gemini 3 Pro Image 和 Gemini Nano Banana 2.1 的文档页。DreamTo 上的全部模型见 /models。

FAQ#

怎样让 Nano Banana 生成的图里文字准确无误?#

把每句话放进引号,说明它放在哪里、出现几次,并在提示词末尾加上“No other text”。文案尽量短,生成后按交付尺寸检查拼写和换行。

怎样通过 API 用 Nano Banana 修改照片?#

把照片作为 inlineData 部分(Base64)或 fileData.fileUri(公开 https 链接)发送,旁边放一个文本部分,写明要改什么、要保留什么。如果不填 aspectRatio,输出会沿用输入图的比例。

最多可以传多少张参考图?#

两个模型都是最多 14 张。Pro 最多 6 张物体图、5 张角色图和 3 张风格参考图;2.1 最多 10 张物体图和 4 张角色图。内联图片可以是 PNG、JPEG、WebP、HEIC 或 HEIF。

在 DreamTo 上用 Nano Banana 生成一张图要多少钱?#

截至 2026 年 12 月,Nano Banana Pro 在 1K 和 2K 下每次请求 $0.03,4K 为 $0.05;Nano Banana 2.1 在 1K 下为 $0.01,2K 为 $0.02,4K 为 $0.03。无效请求和生成失败的请求不计费。最新价格请查看 /prices。

Nano Banana 可以用系统提示词吗?#

暂时不行。两个模型上 systemInstruction 都会返回 400,且不计费,所以请把长期生效的指令写进提示词正文。safetySettings 和 google_search 工具同理。

  • Nano Banana
  • Prompts
  • Image Editing