Corespeed NanoBanana — Gemini Image & Text Generation
Auth: Set CS_AI_GATEWAY_BASE_URL and CS_AI_GATEWAY_API_TOKEN environment variables.
Workflow
- 1. Pick a model from the table below (default:
gemini-2.5-flash-image for image generation) - Run the script with your prompt
Usage
CODEBLOCK0
- -
--prompt, -p — Text prompt (required) - INLINECODE5 ,
-f — Output filename (required) - INLINECODE7 ,
-i — Input image file(s), repeat for multiple - INLINECODE9 ,
-m — Model name (default: gemini-2.5-flash-image) - INLINECODE12 — Response type:
auto, image, text, image+text (default: auto) - INLINECODE18 — Output structured JSON (recommended for agent consumption)
Output format is determined by file extension: .png/.jpg → image generation, .txt/.md → text output.
Image Generation
CODEBLOCK1
Image Analysis
CODEBLOCK2
Text Generation
CODEBLOCK3
Models
| Model | Type | Best For |
|---|
| gemini-2.5-flash-image | Image + Text | Image generation & editing (default) |
| gemini-2.5-flash |
Text | Fast analysis, vision, general tasks |
| gemini-2.5-pro | Text | Complex reasoning, highest quality |
| gemini-2.5-flash-lite | Text | Fastest, simple tasks |
Notes
- - No manual Python setup required. The script uses PEP 723 inline metadata.
uv run automatically creates an isolated virtual environment and installs the google-genai dependency on first run. - Image output is returned inline as base64 from the Gemini API — no separate download step.
- Use timestamps in filenames:
yyyy-mm-dd-hh-mm-ss-name.ext. - Script prints
MEDIA: line for OpenClaw to auto-attach generated images. - Do not read generated media back; report the saved path only.
- Only
gemini-2.5-flash-image can generate images. Other models are text-only. - Use
--json for structured output: INLINECODE29
Support
Built by Corespeed. If you need help or run into issues:
Corespeed NanoBanana — Gemini 图像与文本生成
作者:设置 CSAIGATEWAYBASEURL 和 CSAIGATEWAYAPITOKEN 环境变量。
工作流程
- 1. 从下表中选择一个模型(图像生成默认使用 gemini-2.5-flash-image)
- 使用提示词运行脚本
使用方法
bash
uv run {baseDir}/scripts/gemini.py --prompt 你的提示词 -f 输出文件.ext [-i 输入文件.ext] [--model 模型名称]
- - --prompt, -p — 文本提示词(必填)
- --filename, -f — 输出文件名(必填)
- --input, -i — 输入图像文件,可重复使用以添加多个文件
- --model, -m — 模型名称(默认:gemini-2.5-flash-image)
- --modalities — 响应类型:auto、image、text、image+text(默认:auto)
- --json — 输出结构化 JSON(推荐用于代理消费)
输出格式由文件扩展名决定:.png/.jpg → 图像生成,.txt/.md → 文本输出。
图像生成
bash
文本到图像
uv run {baseDir}/scripts/gemini.py -p 秋日森林中的水彩狐狸 -f fox.png
图像编辑
uv run {baseDir}/scripts/gemini.py -p 移除背景,添加海滩日落 -f edited.png -i photo.jpg
多图像合成
uv run {baseDir}/scripts/gemini.py -p 将这两个场景融合在一起 -f blend.png -i scene1.png -i scene2.png
图像分析
bash
描述图像
uv run {baseDir}/scripts/gemini.py -p 描述这张图像 -f desc.txt -i photo.jpg --model gemini-2.5-flash
比较图像
uv run {baseDir}/scripts/gemini.py -p 有哪些不同? -f diff.txt -i before.jpg -i after.jpg --model gemini-2.5-flash
文本生成
bash
使用最强大的模型处理复杂任务
uv run {baseDir}/scripts/gemini.py -p 写一首关于编程的俳句 -f haiku.txt --model gemini-2.5-pro
模型
| 模型 | 类型 | 最佳用途 |
|---|
| gemini-2.5-flash-image | 图像 + 文本 | 图像生成与编辑(默认) |
| gemini-2.5-flash |
文本 | 快速分析、视觉、通用任务 |
| gemini-2.5-pro | 文本 | 复杂推理、最高质量 |
| gemini-2.5-flash-lite | 文本 | 最快、简单任务 |
注意事项
- - 无需手动设置 Python。 该脚本使用 PEP 723 内联元数据。uv run 会自动创建隔离的虚拟环境,并在首次运行时安装 google-genai 依赖。
- 图像输出以 base64 格式从 Gemini API 内联返回——无需单独下载步骤。
- 在文件名中使用时间戳:yyyy-mm-dd-hh-mm-ss-名称.ext。
- 脚本会打印 MEDIA: 行,供 OpenClaw 自动附加生成的图像。
- 不要读取生成的媒体文件;仅报告保存的路径。
- 只有 gemini-2.5-flash-image 可以生成图像。其他模型仅支持文本。
- 使用 --json 获取结构化输出:{ok: true, files: [...], text: ..., model: ..., tokens: {...}}
支持
由 Corespeed 构建。如需帮助或遇到问题: