Install
openclaw skills install img2-generate-only独立单图 IMG2 生图 Skill。必须显式提供接口地址和密钥,调用 OpenAI 兼容图片接口生成单张图片并本地落盘。
openclaw skills install img2-generate-only这是一个纯单图生图 Skill。
它只做一件事:
prompt → 调用 IMG2 / gpt-image-2 → 本地落盘 → 返回结构化结果
它不依赖任何历史本地配置,也不包含你们之前环境里的私有 provider 配置。
使用时必须由用户或工作流显式提供入参。
它不负责:
python3 /home/ye/.openclaw/workspace/scripts/img2_generate_only.py
下面这些参数必须由用户显式提供:
prompt最终图片提示词。
base_url图片接口基础地址。
例如:
https://your-api.example.com/v1
脚本会自动请求:
{base_url}/images/generations
api_key接口密钥。
例如:
sk-xxxx
model图片模型名称。
当前标准推荐:
gpt-image-2
size图片尺寸。
例如:
1024x1024
task_name任务名,用于输出文件命名。
timeout_ms单张图最长等待时间,单位毫秒。
推荐:
300000
output_dir图片输出目录。
默认:
/tmp/generated-images
response_format返回格式。
默认推荐:
b64_json
n生成数量。
当前这个 Skill 只支持单图,必须为:
1
return_base64是否在结果中返回 base64。
默认:
false
一般不建议开启,返回 image_path 更稳。
{
"prompt": "一只毛茸茸的橘猫坐在窗边,真实摄影风格,阳光柔和,无文字,无水印",
"base_url": "https://your-api.example.com/v1",
"api_key": "sk-xxxx",
"model": "gpt-image-2",
"size": "1024x1024",
"task_name": "orange-cat-window",
"timeout_ms": 300000,
"output_dir": "/tmp/generated-images",
"response_format": "b64_json",
"n": 1,
"return_base64": false
}
python3 /home/ye/.openclaw/workspace/scripts/img2_generate_only.py '{
"prompt": "一只毛茸茸的橘猫坐在窗边,真实摄影风格,阳光柔和,无文字,无水印",
"base_url": "https://your-api.example.com/v1",
"api_key": "sk-xxxx",
"model": "gpt-image-2",
"size": "1024x1024",
"task_name": "orange-cat-window",
"timeout_ms": 300000,
"output_dir": "/tmp/generated-images",
"response_format": "b64_json",
"n": 1,
"return_base64": false
}'
python3 /home/ye/.openclaw/workspace/scripts/img2_generate_only.py \
--prompt "一只毛茸茸的橘猫坐在窗边,真实摄影风格,阳光柔和,无文字,无水印" \
--base_url "https://your-api.example.com/v1" \
--api_key "sk-xxxx" \
--model gpt-image-2 \
--size 1024x1024 \
--task_name orange-cat-window \
--timeout_ms 300000 \
--output_dir /tmp/generated-images
{
"ok": true,
"stage": "done",
"image_path": "/tmp/generated-images/orange-cat-window-20260508-094000.png",
"bytes": 1544093,
"base_url": "https://your-api.example.com/v1",
"model": "gpt-image-2",
"size": "1024x1024"
}
如果 return_base64=true,还会额外返回:
{
"b64": "..."
}
失败时返回结构化 JSON:
{
"ok": false,
"stage": "request",
"http_status": 502,
"upstream_error_type": "upstream_error",
"upstream_error_message": "Upstream request failed",
"error": "脱敏后的错误信息",
"diagnosis": {
"category": "upstream_failure",
"human_reason": "图片模型上游服务失败或临时不可用;不是本地脚本问题。",
"retryable": true
}
}
工作流建议读取:
okstagehttp_statusupstream_error_typeupstream_error_messagediagnosis.categorydiagnosis.human_reasondiagnosis.retryable这个 Skill 只负责单张图生成。
如果用户需要:
那应该使用单独的批量调度器,而不是把这些逻辑塞进这个单图 Skill 里。
这是一个纯独立单图 IMG2 生图节点:用户必须显式提供 prompt + base_url + api_key + model + size + task_name + timeout_ms,脚本返回本地图片路径和结构化状态。