Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when the user wants to generate or edit images with Google's Nanobanana/Gemini image models using the official Gemini API shape, or when they need publication-style scientific figures rendered exactly from data with the bundled Python plotting tool. Prefer this skill for text-to-image, image-to-image editing, multi-image reference workflows, attachment-based recreations, exact bar/trend/heatmap/scatter plots, or when the user wants publication-style figures such as materials-science paper sc
.claude/skills/leoyeai-nanobanana-image-generation/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 30% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 167% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 273% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 174% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 255% | 0% |
This skill now supports two modes:
image modeGemini or Nanobanana generation and editing through the official generateContent flow
plot modeExact Python or matplotlib rendering of publication-style figures from numeric data
Use image mode for mechanism figures, graphical abstracts, device schematics, style-matched redraws, and diagram-first work. Use plot mode for exact bar charts, trend curves, heatmaps, scatter plots, and multi-panel figures that must preserve numeric truth.
Runtime policy:
image and plot workflows.scripts/generate_image.js is an optional parity CLI for environments that already use Node.js, not the required runtime baseline for registry gating.When the user is working in Codex and describes a plot in natural language, do not require them to hand-write a JSON spec. Codex should translate the request into an internal plot request or spec and run the plotting scripts.
For image mode, follow Google's official examples and replace:
Do not use OpenAI-style /images/generations or /images/edits routes for this skill.
If the image exists only as a chat attachment and the platform does not expose a local file path, do not claim the script can upload it directly.
Use this rule:
For requests like "replace the English text in this attached image with Chinese", the fallback recreation workflow is acceptable when exact pixel-preserving edit is impossible.
Preflight:
plot mode is local-only and does not require API credentials or outbound network access.image mode sends prompt text, API credentials, and any --input-image files to the configured Gemini-compatible endpoint.--allow-third-party or NANOBANANA_ALLOW_THIRD_PARTY=1 and treat that as an explicit trust decision.Set environment variables:
bashexport NANOBANANA_API_KEY="your-provider-key" export NANOBANANA_BASE_URL="https://generativelanguage.googleapis.com" export NANOBANANA_MODEL="gemini-3.1-flash-image-preview"
Optional third-party provider:
bashexport NANOBANANA_BASE_URL="https://api.zhizengzeng.com/google" export NANOBANANA_ALLOW_THIRD_PARTY=1
If you do not want the API key to appear in the command line, store it in a file and use:
bashexport NANOBANANA_API_KEY_FILE="$PWD/.secrets/nanobanana_api_key"
Generate an image:
bashpython3 scripts/generate_image.py "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"
Edit an image:
bashpython3 scripts/generate_image.py "Using the provided image, change only the blue sofa to a vintage brown leather Chesterfield sofa. Keep everything else exactly the same." --input-image ./living-room.png
Recreate an attached diagram with translated labels:
bashpython3 scripts/generate_image.py "Recreate the attached pastel technical diagram with the same layout, icons, arrows, and hand-drawn style. Replace all visible English labels with natural Simplified Chinese. Keep the composition unchanged." --aspect-ratio 16:9 --image-size 2K
Safety note:
scripts/build_materials_figure_prompt.py and --print-prompt are local-only and do not send data over the network.--allow-third-party or NANOBANANA_ALLOW_THIRD_PARTY=1.NANOBANANA_API_KEY_FILE over inline --api-key when you do not want the key to appear in shell history.Choose a mode first:
plot mode.Read references/publication-plot-api.md and run scripts/plot_publication_figure.py. For natural-language requests, also read references/natural-language-plot-workflow.md.
image mode.Follow the Gemini generateContent flow below.
For image mode:
Use POST /v1beta/models/{model}:generateContent with X-goog-api-key.
contents[].parts.Text-only generation uses one text part. Image editing appends one or more inline image parts.
generationConfig.imageConfig.Prefer --aspect-ratio and --image-size, matching the official docs.
Use python3 scripts/build_materials_figure_prompt.py --materials-figure ... when you want to inspect or refine the prompt before sending any API request.
Read references/publication-figure-design.md for house style, palette semantics, typography, and panel logic.
Use those patterns to specify grouped bars, heatmaps, trend layouts, dedicated legends, and wide comparison panels.
candidates[0].content.parts[].inlineData.Save text parts too when returned.
Ask for a local path for exact editing. Use recreation if the user wants the result and accepts a visually matched redraw.
For plot mode:
Do not ask the user to author the internal spec unless they explicitly want low-level control.
scripts/build_plot_spec.py.style, layout, and panels.bar, trend, heatmap, scatter, legend, or empty panels.bashpython3 skills/nanobanana-image-generation/scripts/plot_publication_figure.py spec.json
Required:
NANOBANANA_API_KEYNANOBANANA_BASE_URLMust be set explicitly. Official Google endpoint: https://generativelanguage.googleapis.com
Optional:
NANOBANANA_MODELDefault: gemini-3.1-flash-image-preview
NANOBANANA_TIMEOUTDefault: 120
NANOBANANA_API_KEY_FILEPath to a file containing the API key. Prefer this when you do not want the key shown in command history or command logs.
NANOBANANA_ALLOW_THIRD_PARTYSet to 1 only when you intentionally want to send API keys and user-provided files to a non-official Gemini-compatible provider.
scripts/generate_image.pyPython CLI that follows the official Gemini generateContent request shape.
scripts/generate_image.jsNode.js CLI with the same request format.
scripts/plot_publication_figure.pyPython CLI for exact publication-style plotting from JSON specs.
scripts/build_plot_spec.pyPython CLI that expands a concise request JSON into a full plotting spec.
Common options:
--input-image ./source.png--prompt-file ./background.md--aspect-ratio 16:9--image-size 2K--text-only--thinking-level high--include-thoughts--materials-figure mechanism-figure--lang zh--style-note "Nature Energy style"--print-prompt--allow-third-party--api-key-file ./.secrets/nanobanana_api_keyDefault output location:
./output/nanobanana/ relative to the current Codex working directoryDeterministic plotting:
bashpython3 skills/nanobanana-image-generation/scripts/plot_publication_figure.py ./spec.json \ --out-path ./output/plots/result \ --formats png pdf svg \ --dpi 300
Natural-language-friendly internal workflow:
bashpython3 skills/nanobanana-image-generation/scripts/build_plot_spec.py ./request.json --out ./spec.json python3 skills/nanobanana-image-generation/scripts/plot_publication_figure.py ./spec.json
Official Google examples:
api_key="GEMINI_API_KEY"base_url="https://generativelanguage.googleapis.com"Third-party provider replacements:
api_key="your_provider_api_key"base_url="your_google_compatible_endpoint"allow_third_party=trueOptional Zhizengzeng example:
api_key="your_zzz_api_key"base_url="https://api.zhizengzeng.com/google"allow_third_party=trueEverything else should stay aligned with the official Gemini documentation.
zh-CN prompts when image fidelity matters.If the user asks for a materials-science paper figure, journal-style scientific schematic, graphical abstract, mechanism diagram, synthesis workflow figure, microstructure-property diagram, device architecture figure, or characterization-plan figure, use the bundled materials-science templates instead of writing the prompt from scratch.
Workflow:
graphical-abstractmechanism-figuredevice-architectureprocessing-workflowenzhScientific Background slot, or use the script shortcut directly.--prompt-file or scripts/build_materials_figure_prompt.py --background-file ... instead of squeezing it into one shell argument.This skill includes a distilled publication-figure playbook adapted from the figures4papers project. Use it to make Nanobanana outputs look like journal figures rather than generic AI art.
Read the reference files only as needed:
Use for overall figure art direction: typography, palette semantics, panel hierarchy, white-background policy, legend handling, and print-safe simplification.
Use when the figure contains bars, trend lines, heatmaps, comparison matrices, or dedicated legend panels.
Apply these rules when prompting:
This skill is strong for:
This skill is not a guarantee of exact quantitative plotting. If the user needs exact bar heights, exact heatmap values, or faithful axis tick math from raw numbers, treat Nanobanana as a layout or visual-direction tool unless the request is explicitly a redraw from a trusted reference image.
For exact plotting, switch to plot mode and use references/publication-plot-api.md plus scripts/plot_publication_figure.py.
Python shortcut:
bashpython3 scripts/generate_image.py "paste the scientific background here" \ --materials-figure mechanism-figure \ --lang en \ --style-note "Benchmark the figure against Nature Materials aesthetics." \ --aspect-ratio 4:3 \ --image-size 2K
JavaScript shortcut:
bashnode scripts/generate_image.js "paste the scientific background here" \ --materials-figure graphical-abstract \ --lang zh \ --aspect-ratio 4:3 \ --image-size 2K
Prompt-only preflight:
bashpython3 scripts/build_materials_figure_prompt.py \ --materials-figure mechanism-figure \ --lang en \ --background-file ./background.md \ --style-note "Nature Materials aesthetic with concise panel labels."
401 or 403, verify NANOBANANA_API_KEY.NANOBANANA_BASE_URL or pass --base-url.--allow-third-party or set NANOBANANA_ALLOW_THIRD_PARTY=1 only if that provider is intentional.404, verify that the request is going to /v1beta/models/{model}:generateContent.candidates[0].content.parts and check whether the request asked for image output.figures4papers.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | fail→fail | 21,909 | 13,350 | -39% | 1 | 1 | 0% | 4,385 | 5,822 | +33% | 0 | 0 | — |
case-01 | fail→fail | 2,716 | 10,280 | +278% | 1 | 1 | 0% | 359 | 4,777 | +1231% | 0 | 0 | — |
case-03 | fail→fail | 29,828 | 10,985 | -63% | 1 | 1 | 0% | 6,195 | 4,678 | -24% | 0 | 0 | — |
case-04 | fail→pass | 20,022 | 3,779 | -81% | 1 | 1 | 0% | 3,534 | 4,610 | +30% | 0 | 0 | — |
case-05 | fail→pass | 10,060 | 3,129 | -69% | 1 | 1 | 0% | 1,777 | 4,741 | +167% | 0 | 0 | — |
case-06 | fail→pass | 6,269 | 3,004 | -52% | 1 | 1 | 0% | 1,260 | 4,703 | +273% | 0 | 0 | — |
case-11 | fail→fail | 13,174 | 3,555 | -73% | 1 | 1 | 0% | 2,184 | 4,694 | +115% | 0 | 0 | — |
case-07 | fail→pass | 11,427 | 7,089 | -38% | 1 | 1 | 0% | 2,011 | 5,513 | +174% | 0 | 0 | — |
case-08 | pass→pass | 12,797 | 6,028 | -53% | 1 | 1 | 0% | 2,005 | 5,338 | +166% | 0 | 0 | — |
case-09 | fail→pass | 8,111 | 3,413 | -58% | 1 | 1 | 0% | 1,348 | 4,789 | +255% | 0 | 0 | — |
case-10 | fail→pass | 9,289 | 1,763 | -81% | 1 | 1 | 0% | 1,514 | 4,384 | +190% | 0 | 0 | — |
case-12 | fail→pass | 8,555 | 3,169 | -63% | 1 | 1 | 0% | 1,383 | 4,559 | +230% | 0 | 0 | — |
case-13 | fail→pass | 21,275 | 8,364 | -61% | 1 | 1 | 0% | 3,291 | 5,370 | +63% | 0 | 0 | — |
case-14 | fail→pass | 7,673 | 3,689 | -52% | 1 | 1 | 0% | 1,129 | 4,716 | +318% | 0 | 0 | — |
case-15 | fail→pass | 13,385 | 4,528 | -66% | 1 | 1 | 0% | 2,221 | 4,916 | +121% | 0 | 0 | — |
case-16 | pass→pass | 13,921 | 7,364 | -47% | 1 | 1 | 0% | 2,095 | 5,400 | +158% | 0 | 0 | — |
case-17 | pass→pass | 9,932 | 9,140 | -8% | 1 | 1 | 0% | 1,517 | 5,306 | +250% | 0 | 0 | — |
case-18 | fail→pass | 11,766 | 2,866 | -76% | 1 | 1 | 0% | 2,136 | 4,617 | +116% | 0 | 0 | — |
case-19 | pass→pass | 11,869 | 12,505 | +5% | 1 | 1 | 0% | 2,064 | 6,218 | +201% | 0 | 0 | — |
case-20 | pass→pass | 9,763 | 9,079 | -7% | 1 | 1 | 0% | 1,789 | 5,655 | +216% | 0 | 0 | — |
case-21 | pass→pass | 11,909 | 6,475 | -46% | 1 | 1 | 0% | 1,999 | 5,373 | +169% | 0 | 0 | — |
case-22 | pass→pass | 9,873 | 4,977 | -50% | 1 | 1 | 0% | 1,526 | 5,092 | +234% | 0 | 0 | — |
case-23 | pass→pass | 5,163 | 2,415 | -53% | 1 | 1 | 0% | 893 | 4,526 | +407% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 21 counted toward the lift figure. The other 2 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +48 percentage points is the difference between those two pass rates over the 21 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.