使用 Google GenAI SDK 通过 Gemini 生成或编辑图像。当用户要求在 OpenCla… 中创建、转换、渲染或保存一张或多张图像时使用。
当您需要从文本提示创建一个或多个图像文件时使用此技能, 或者用双子座编辑一个或多个已有图像是一项面向实际任务的技能,主要用于@% @.openclaw/openclaw.json 必須包括 $.sk。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
当您需要根据文本提示生成一个或多个图像文件,或使用 Gemini 编辑一个或多个现有图像时,请使用此技能。
~/.openclaw/openclaw.json 中必须将 $.skills.entries["gemini-image-generation"].enabled 设置为 true。
~/.openclaw/openclaw.json 中必须包含 $.skills.entries["gemini-image-generation"].env,且该对象需具备以下键值对:
GEMINI_API_KEY(必需)
GEMINI_MODEL_ID(必需)
GEMINI_BASE_URL(可选)
示例 ~/.openclaw/openclaw.json:
{
......,
"skills": {
"entries": {
"gemini-image-generation": {
"enabled": true,
"env": {
"GEMINI_API_KEY": "sk-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"GEMINI_MODEL_ID": "gemini-3.1-flash-image-preview",
"GEMINI_BASE_URL": "https://custom-endpoint.com"
}
}
}
},
......
}
npm install 以安装依赖项。--aspectRatio 和 --imageSize 参数传入。generate-image.mjs,并传入 --prompt、--output 及可选的图像配置参数。edit-image.mjs,并传入 --prompt、一个或多个 --input 值、--output 及可选的图像配置参数。GEMINI_API_KEY 和 GEMINI_MODEL_ID。GEMINI_BASE_URL 中读取基础 URL。MEDIA:(例如:MEDIA:outputs/gemini-native-image.png),以便图像在对话中以内联方式显示。node ./skills/gemini-image-generation/scripts/generate-image.mjs --prompt "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme" --output "outputs/gemini-native-image.png"
node ./skills/gemini-image-generation/scripts/generate-image.mjs --prompt "Create a wide cinematic food photo of a nano banana dish in a fancy restaurant with a Gemini theme" --output "outputs/gemini-wide.png" --aspectRatio "16:9" --imageSize "2K"
node ./skills/gemini-image-generation/scripts/edit-image.mjs --prompt "Turn this cat into a watercolor illustration eating a nano-banana in a fancy restaurant under the Gemini constellation" --input "inputs/cat.png" --output "outputs/cat-watercolor.png" --aspectRatio "5:4" --imageSize "2K"
node ./skills/gemini-image-generation/scripts/edit-image.mjs --prompt "Create an office group photo of these people making funny faces" --input "inputs/person-1.jpg" --input "inputs/person-2.jpg" --input "inputs/person-3.jpg" --output "outputs/group-photo.png"
TEXT: 开头打印模型输出的文本内容,以 IMAGE: 开头打印每个已保存图像的路径。MEDIA:,以确保图像与对应路径一同在对话中以内联方式渲染。name-1.png、name-2.png 等形式。edit-image.mjs 支持重复使用 --input 标志。您也可向单个 --input 参数传入逗号分隔的路径列表。edit-image.mjs 会根据输入文件扩展名(.png、.jpg、.jpeg 或 .webp)自动推断源图像 MIME 类型。如需显式指定,可统一使用一个 --mime-type 参数,或为每个 --input 单独配对一个 --mime-type。--aspectRatio 和 --imageSize 参数,也支持其短横线格式(kebab-case):即 --aspect-ratio 和 --image-size。config.imageConfig 字段。相关专题
热门下载
相关下载
精品课程
共0课时 | 0人学习
共0课时 | 0人学习
共0课时 | 0人学习
最新文章