提示詞指南

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 端點。API 金鑰放在 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 下可能出現拼接瑕疵(tiling artifacts),2.1 的文件也列了修正方法。

修圖提示詞:說清楚要改什麼、要保留什麼#

修圖時,把圖片放進一個 inlineData part(或以公開連結放在 fileData.fileUri),和文字 part 一起送出。下指令的方式就像交代修圖師:先說要改什麼,再說哪些必須保持不變。

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,做法是把模型先前回傳的 parts 原封不動送回去。不過直接拿定稿圖當參考圖、發一次新的請求,寫成腳本比較簡單。

多參考圖提示詞:說清楚每張圖的用途#

兩個模型每次請求最多都能接收 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 模型頁對一致性的建議寫的:準備一張清楚的角色參考圖、指出會改變的姿勢或場景,並列出要保留的細節。接著逐個場景比對髮型、服裝和色調。

若需要風格參考圖,或要在同一張圖中放入第 5 個角色,請選 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 的價格相同。

Nano Banana 2(gemini-3.1-flash-image)也就是 2.1 的前一版,同樣可以使用。在動手寫程式之前,你可以先到 Nano Banana Pro Playground或 Nano Banana 2.1 Playground試跑這些提示詞。

想進一步了解尺寸與參考圖,請參閱 Nano Banana Pro API 使用指南和 Nano Banana 2.1、Pro、2、2 Lite 比較。AI 商品圖提示詞怎麼寫則更深入談型錄用的商品圖。

API 目前的限制#

  • 尚不支援 systemInstruction、safetySettings 和 tools(包括以 Google 搜尋建立基準的 grounding)。這些參數會回傳 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 part(Base64)或 fileData.fileUri(公開 https 連結),和一個文字 part 一起送出,文字裡寫清楚要改什麼、要保留什麼。如果省略 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