image-generator
Generate images with Gemini image models (Nano Banana Pro) and display them in chat.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 3
- Forks
- 2
01 前言 Front Matter
- name
- image-generator
- description
- Generate images with Gemini image models (Nano Banana Pro) and display them in chat.
02 资源文件 1
- 脚本generate_image.py6.7 KB
03 SKILL.md 正文
image-generator
Generate images using Gemini image models (default: gemini-3-pro-image-preview, Nano Banana Pro class).
Auth (preferred): set GEMINI_API_KEY or GOOGLE_API_KEY in the agent .env (Google AI Studio).
Fallback: Vertex AI via GCP_PROJECT_ID / VERTEX_AI_PROJECT_ID / GOOGLE_CLOUD_PROJECT plus Application Default Credentials.
When to use
- The user asks for a new image, illustration, diagram, or visual asset
- You need a PNG saved under
./generated-media/images/for follow-up or display
How to run
Shell commands start in workspace root. The trusted generator script is in
the separate read-only skills root from list_skills; generated output remains
workspace-relative.
- Confirm
list_skillsincludesimage-generatorand noteskills_path. - Run the generator with
run_commandand directpython3argv (do not wrap inbash -c— that can pick a system Python withoutgoogle-genai):
{
"argv": [
"python3",
"<skills_path>/image-generator/generate_image.py",
"--prompt",
"A minimalist logo of a monkey astronaut, flat vector style",
"--aspect-ratio",
"16:9"
],
"timeout": 180
}
Replace <skills_path> with the skills_path returned by list_skills (skills).
Supported --aspect-ratio values: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9.
-
Parse JSON stdout from the command result:
- Success:
{"ok": true, "path": "./generated-media/images/<uuid>.png", "prompt": "...", ...} - Failure:
{"ok": false, "error": "..."}
- Success:
-
Call
load_filewith the returnedpathonly. That emits anImageBlockto the chat UI (and loads pixels into model context on vision-capable providers):
load_file(path="<path from script>")
Do not use read_file on the PNG — that is for text files only.
- Caption the image using the
--promptyou submitted (or the echoedpromptfield). Do not invent a different subject from memory or earlier chats. On text-only providers you will not see pixels — still describe from this turn's prompt.
Notes
- Output files are written under
./generated-media/images/(allowed byrun_commandpolicy). - Do not paste raw base64 in chat; always use
load_fileafter generation. - On failure, report the
errorfield and do not callload_file. Neverglobfor**/*.pngand load an arbitrary older file as a substitute. - Do not use the
tasktool for this skill — run the steps above yourself. python3/pythoninrun_commanduse the gateway interpreter (which includesgoogle-genaivia monkeybot). Do not runpip install/uv pip installviarun_command— installs are blocked by policy.
04 同仓库更多 Skills
browser
Smoke-test browser skill fixture.
plain
暂无简介
diagnostics
Inspect a failing run and report the first error.
nested
Nested skills must not be discovered.
image-generator
Generate images with Gemini image models (Nano Banana Pro) and display them in chat.
diagnostics
Run deployment health checks (env, runtime, computation) and return JSON status.