image-gen
它能做什么
这项技能通过 OpenRouter,使用 Google 的 Nano Banana 图像模型,根据你的文字描述创建图片。适合想让 AI 绘制插图、示意图或场景的任何人。
适用场景
- ✓当你要求 AI 绘制、描绘或渲染一张图片时。
- ✓当你想根据简短描述生成示意图或场景时。
- ✓当你想根据描述加上一张或多张输入图片来生成图片时。
技能链接
https://github.com/EverMind-AI/Raven/blob/main/demos/skill_retrieval/skills/image-gen/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请画一只友好的卡通狐狸,在树下读书。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体通过 OpenRouter 把你的描述发送给图像模型,要求输出图片,并把返回的图片保存为文件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
image-gen — Nano Banana via OpenRouter
Generates one or more images from a text prompt (and optionally one or more input images) by calling Google's Nano Banana family on OpenRouter:
google/gemini-2.5-flash-image— original (Nano Banana)google/gemini-3.1-flash-image-preview— latest (Nano Banana 2)
OpenRouter speaks the OpenAI-compatible chat-completions API for these models, with two extras:
- The request must include
"modalities": ["image", "text"]so the server knows to return image bytes, not just a description. - The response carries images in a top-level
message.imagesarray (NOT incontent— that field still holds optional commentary text).
Quick recipe
import os, base64, json, urllib.request
KEY = os.environ["OPENROUTER_API_KEY"]
MODEL = "google/gemini-2.5-flash-image" # or 3.1 for "Nano Banana 2"
def generate_image(prompt: str, out_path: str = "out.png") -> str:
req = urllib.request.Request(
"https://openrouter.ai/api/v1/chat/completions",
data=json.dumps({
"model": MODEL,
"messages": [{"role": "user", "content": prompt}],
"modalities": ["image", "text"],
}).encode(),
headers={
"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json",
},
method="POST",
)
with urllib.request.urlopen(req, timeout=120) as resp:
data = json.loads(resp.read())
msg = data["choices"][0]["message"]
# ``message.images[i].image_url.url`` is a data URI:
# "data:image/png;base64,<base64-bytes>"
url = msg["images"][0]["image_url"]["url"]
b64 = url.split(",", 1)[1]
with open(out_path, "wb") as f:
f.write(base64.b64decode(b64))
text_note = msg.get("content") or ""
return f"Wrote {out_path} ({len(b64)//1024} KB). Model said: {text_note[:200]!r}"
Request shape (full)
{
"model": "google/gemini-2.5-flash-image",
"messages": [
{"role": "user", "content": "A red circle on white background"}
],
"modalities": ["image", "text"]
}
For image input + image output (edit / vary / extend), use the standard
multipart content form OpenAI clients accept. The image part can be either
a remote URL or a base64 data URI:
{
"role": "user",
"content": [
{"type": "text", "text": "Make this watercolor style"},
{"type": "image_url",
"image_url": {"url": "data:image/png;base64,iVBORw0KGgo..."}}
]
}
Response shape
{
"choices": [{
"message": {
"role": "assistant",
"content": "optional text commentary",
"images": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,<bytes>"
}
}
]
}
}],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 1295,
"total_tokens": 1303,
"cost": 0.0383,
"completion_tokens_details": {"image_tokens": 1290}
}
}
Cost (observed)
~$0.04 per 1024×1024 PNG at the time of writing (1290 image tokens × $0.00003/tok via the v2.5 flash-image model). Burst test: 10 images ≈ $0.40. Budget gates accordingly when looping in agent code.
When to use this skill
Trigger keywords / patterns you should recognize:
- "generate / create / make / draw / render / illustrate (an image / a picture / a logo / ...)"
- "show me what X looks like"
- "design a banner / poster / icon for ..."
- "make it watercolor / cyberpunk / pencil sketch / pixel art" (edit existing)
- "vary this image" / "more like this but with ..."
Don't use this skill for:
- Charts / plots from data → prefer a Python plotting skill (matplotlib / plotly) rather than a generative image. Charts need accurate numbers; Nano Banana will hallucinate axes.
- Diagrams with precise structure (UML, DAGs) → use mermaid / graphviz instead.
Troubleshooting
- Empty
imagesarray: you forgot"modalities": ["image", "text"]. OpenRouter falls back to text-only without it. - HTTP 403 with "not available in your region": OpenRouter blocks
Anthropic + some Google models from China-mainland IPs. Set
HTTPS_PROXYto a proxy that exits via a non-blocked region. - Response includes
refusal: prompt was content-filtered. Rewrite the prompt; don't retry the same string. - PNG opens to blank / corrupt: you wrote the data URI verbatim
常见问题
它使用哪些模型?
它使用 Google 的 Gemini 2.5 Flash Image 模型,以及较新的 Gemini 3.1 Flash Image 预览版。
需要账号吗?
需要。它需要在环境变量中设置 OpenRouter API 密钥。
我可以使用自己的图片吗?
可以。它可以把一张或多张输入图片与文字提示词一起使用。
详情
作者的原始描述
Generate images via Nano Banana (Gemini 2.5/3.1 Flash Image) on OpenRouter. Use when the user asks to draw, illustrate, render or generate any kind of picture/diagram/scene.
repo: EverMind-AI/Raven
热度
- GitHub 星标
- 6.0k
- 排名
- #14472
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
deck-to-pptx
6.0k教你的智能体用 python-pptx 制作真正的 PowerPoint .pptx 文件,包括图标、图表、公式以及本环境中的工具。
ppt-script-authoring
6.0k教你的智能体围绕清晰的故事设计幻灯片,并使用自定义版式,以 python-pptx 程序的形式制作。
multi-agent-coding
6.0k帮你的智能体把编程工作交给合适的编程智能体,每项任务启动一个新智能体,并通过文件在各步骤之间传递结果。
raven-self-config
6.0k帮你的智能体查看并修改 Raven 应用自身的设置,例如连接智能体和聊天应用,并解释某项能力为何缺失。