apiyi-gpt-image-2-gen(基于API易代理站)-官转版

v1.0.0

图片生成技能,当用户需要生成图片、视觉信息图、创建图像、编辑/修改/调整已有图片时使用此技能。基于API易平台(https://api.apiyi.com/)的ChatGPT Image 2模型(gpt-image-2)的官方正式版图片生成服务。该模型支持精确的尺寸/画质控制(含4K),按token计费。与gpt...

0· 77·0 current·0 all-time
by无处不在@wuchubuzai2018

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for wuchubuzai2018/apiyi-gpt-image-2-gen.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "apiyi-gpt-image-2-gen(基于API易代理站)-官转版" (wuchubuzai2018/apiyi-gpt-image-2-gen) from ClawHub.
Skill page: https://clawhub.ai/wuchubuzai2018/apiyi-gpt-image-2-gen
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install apiyi-gpt-image-2-gen

ClawHub CLI

Package manager switcher

npx clawhub@latest install apiyi-gpt-image-2-gen
Security Scan
Capability signals
Requires sensitive credentials
These labels describe what authority the skill may exercise. They are separate from suspicious or malicious moderation verdicts.
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
medium confidence
Purpose & Capability
The name/description (GPT Image 2 image generation) match the included Node and Python scripts and the runtime instructions which call api.apiyi.com endpoints. The code and instructions do what the description says. Minor issue: the metadata lists no required env vars, but both SKILL.md and the scripts require an APIYI_API_KEY (or -k argument).
Instruction Scope
SKILL.md instructs the agent to run local Node/Python scripts that read user-supplied prompt and optional local image files, then upload them to https://api.apiyi.com/v1/images/generations or /v1/images/edits. The instructions do not request unrelated system files or other credentials, nor do they transmit data to unexpected endpoints.
Install Mechanism
This is instruction-only with included scripts; no installer or remote download is performed. Python requires the requests package (script exits if missing). Node script is zero-dependency. No high-risk installs or external download URLs are present.
!
Credentials
The runtime requires an API key (APIYI_API_KEY) or the -k/--api-key argument to authenticate to api.apiyi.com, which is proportional to the skill's purpose. However, the skill's declared registry metadata lists no required environment variables or primary credential — this mismatch is important because a user or platform may not realize they must supply the API key. No other unrelated secrets are requested.
Persistence & Privilege
The skill does not request always:true, does not modify other skills or system configuration, and is user-invocable only. It reads/writes only files the user specifies (input images, output files).
Assessment
This skill appears to be what it claims: a client that uploads prompts and (optionally) local images to api.apiyi.com. Before installing or running it: 1) Know that the scripts will send your prompt text and any input images to api.apiyi.com — if those contain sensitive content do not upload them. 2) The SKILL.md and scripts expect APIYI_API_KEY (or use -k when invoking), but the registry metadata did not declare this — set the key yourself and verify you trust api.apiyi.com. 3) Review the included scripts (they are small and readable) and run them in an isolated environment if you have concerns. 4) Ensure Python's requests is installed when using Python, or run the Node script which has no dependencies. 5) If you need stronger assurance, contact the skill author/source (none listed here) or prefer a skill whose metadata explicitly declares required credentials and origin.

Like a lobster shell, security has layers — review code before you run it.

latestvk971nak5hcy18ht37avwqe3fhx85f3w5
77downloads
0stars
1versions
Updated 3d ago
v1.0.0
MIT-0

图片生成与编辑(GPT Image 2 官方正式版)

基于API易平台的GPT Image 2模型(gpt-image-2)官方正式版实现图片生成技能,可以通过自然语言帮助用户生成图片,通过API易国内代理服务访问,支持Node.js和Python两种运行环境。gpt-image-2是API易平台的官方正式版GPT图像生成模型,支持精确的尺寸/画质控制(含4K),按token计费。

使用指引

遵循以下步骤:

第1步:分析需求与参数提取

  1. 明确意图:区分用户是需要【文生图】(生成新图片)还是【图生图】(编辑/修改现有图片)或【多图融合】。

  2. 提示词(Prompt)分析

    • 使用用户原始完整输入:把用户输入的原始完整问题需求描述(原文)直接作为 -p 提示词的主体,避免自行改写、总结或二次创作,防止细节丢失。
    • 需要补充时先确认:如果信息不足(例如缺少风格、主体数量、镜头语言、场景细节、文字内容、禁止元素等),先向用户提问确认;用户确认后,再把补充内容以"追加"的方式拼接到原始提示词后。
    • 样例:
      • 用户输入:"帮我生成一张猫的图片,风格要可爱一点。"
      • 正例说明:直接使用用户输入作为提示词:-p "帮我生成一张猫的图片,风格要可爱一点。"
      • 反例说明:擅自改写为"生成一张可爱风格的猫的图片"会丢失用户原始输入的细节和语气。
      • 如果需要补充细节(例如颜色、背景等),先提问确认:"你希望猫是什么颜色的?背景有什么要求吗?"用户回答后,再追加到提示词中:-p "帮我生成一张猫的图片,风格要可爱一点。猫是橘色的,背景是草地。"
  3. 关键参数整理

    • Prompt(必需):提示词分析后的最终提示词(默认=用户原始完整且一致的输入;仅在用户确认后才追加补充信息)。
    • Filename(可选):输出图片文件名/路径(需包含文件随机标识,避免重复)。不传则脚本会自动生成带时间戳的文件名。建议根据内容生成合理文件名(例如 cat_in_garden.png),避免使用通用名。
    • Size(可选):输出尺寸。
      • 预设值:1024x10241536x10241024x15362048x20482048x11523840x21602160x3840
      • 也可使用自定义尺寸(满足:最大边≤3840、两边16倍数、比例≤3:1、总像素0.65–8.3MP)
      • 默认由模型自适应(auto)
    • Quality(可选):画质档位。low(草图/批量)、medium(日常)、high(终稿/精细文字)、auto(默认)
    • Output Format(可选)png(默认)、jpegwebp
    • Output Compression(可选):输出压缩率(0-100),仅jpeg/webp生效
    • 注意:该模型使用官方正式版端点,与官逆版gpt-image-2-all不同。

第2步:环境检查与命令执行

  1. 检查环境:确认 APIYI_API_KEY 环境变量是否已设置(通常假定已设置,若运行失败再提示用户)���

  2. 构建并运行命令

    • 优先尝试 Node.js 版本:如果环境有 Node(node 命令可用),优先使用 scripts/generate_image.js(零依赖,参数与 Python 保持一致)。
    • Node 不可用再用 Python 版本:使用 scripts/generate_image.py

    文生图命令模板(优先 Node.js):

    node scripts/generate_image.js -p "{prompt}" -f "{filename}" [-s {size}] [-q {quality}] [-o {output_format}]
    

    图生图命令模板(优先 Node.js):

    node scripts/generate_image.js -p "{edit_instruction}" -i "{input_path}" -f "{output_filename}" [-s {size}] [-q {quality}]
    

    多图融合命令模板(优先 Node.js):

    node scripts/generate_image.js -p "融合图1和图2的风格" -i ref1.png ref2.png -f "merged.png" [-s {size}] [-q {quality}]
    

    (可选)Python 版本命令模板(Node 不可用时)

    python scripts/generate_image.py -p "{prompt}" -f "{filename}" [-s {size}] [-q {quality}] [-o {output_format}]
    python scripts/generate_image.py -p "{edit_instruction}" -i "{input_path}" -f "{output_filename}" [-s {size}] [-q {quality}]
    

⏱️ 长时间任务处理策略

1. 任务前提示

执行前必须告知用户

  • "图片生成已启动,预计需要120-150秒,请耐心等待"

2. 🎨 最佳实践示例

"图片生成中,预计120-150秒完成...\n⏳ 正在生成...\n(high + 2K/4K 复杂场景可能需要更长时间,请耐心等待)"

第3步:结果反馈

  1. 执行反馈:等待终端命令执行完毕。
  2. 成功:告知用户图片已生成,并指出保存路径。
  3. 失败
    • 若提示 API Key 缺失,请指导用户设置环境变量。
    • 若提示网络错误,建议用户检查网络或稍后重试。

命令行使用样例

生成新图片

python scripts/generate_image.py -p "图片描述文本" -f "output.png" [-s {size}] [-q {quality}] [-o {output_format}]

示例:

# 基础生成
python scripts/generate_image.py -p "一只可爱的橘猫在草地上玩耍" -f "cat.png"

# 指定尺寸和画质
python scripts/generate_image.py -p "日落山脉风景" -f "sunset.png" -s "2048x1152" -q "high"

# 竖版高清图片(适合手机壁纸)
python scripts/generate_image.py -p "城市夜景" -f "city.png" -s "2160x3840" -q "high"

# 输出为JPEG
python scripts/generate_image.py -p "风景照片" -f "landscape.jpg" -s "3840x2160" -q "high" -o "jpeg"

(可选)Node.js 版本示例:

# 基础生成
node scripts/generate_image.js -p "一只可爱的橘猫在草地上玩耍" -f "cat.png"

# 指定尺寸和画质
node scripts/generate_image.js -p "日落山脉风景" -f "sunset.png" -s "2048x1152" -q "high"

编辑已有图片

python scripts/generate_image.py -p "编辑指令" -f "output.png" -i "path/to/input.png" [-s {size}] [-q {quality}]

示例:

# 修改风格
python scripts/generate_image.py -p "将图片转换成水彩画风格" -f "watercolor.png" -i "original.png"

# 添加元素
python scripts/generate_image.py -p "在天空添加彩虹" -f "rainbow.png" -i "landscape.png" -q "high"

# 替换背景
python scripts/generate_image.py -p "将背景换成海滩" -f "beach-bg.png" -i "portrait.png" -s "2048x2048"

(可选)Node.js 版本示例:

# 修改风格
node scripts/generate_image.js -p "将图片转换成水彩画风格" -f "watercolor.png" -i "original.png"

# 多��参考图融合(最多5张)
node scripts/generate_image.js -p "把图1的人物放进图2的场景" -i ref1.png ref2.png -f "merged.png"

附加资源

  • 尺寸与比例控制文档:references/size-guide.md

命令行参数说明

Python 与 Node.js 版本参数保持一致(短参数与长参数等价)。

参数必填说明
-p / --prompt图片描述(文生图)或编辑指令(图生图)。保留用户原始完整输入。
-f / --filename输出图片路径/文件名;不传则自动生成带时间戳的文件名。
-s / --size输出尺寸:1024x1024 / 1536x1024 / 1024x1536 / 2048x2048 / 2048x1152 / 3840x2160 / 2160x3840 或自定义尺寸。
-q / --quality画质档位:low / medium / high / auto(默认auto)。
-o / --output-format输出格式:png(默认)/ jpeg / webp。
-c / --output-compression输出压缩率(0-100),仅jpeg/webp生效。
-i / --input-image图生图输入图片路径;可传多张(最多5张)。传入该参数即进入编辑模式。

尺寸说明

预设尺寸

尺寸比例适用场景
1024x10241:1头像、Instagram帖子
1536x10243:2标准横版
1024x15362:3标准竖版
2048x20481:1高清方图
2048x115216:9横版视频封面、桌面壁纸
3840x216016:94K超高清
2160x38409:16竖版4K

自定义尺寸

可使用任意合法自定义尺寸,需满足:

  • 最大边 ≤ 3840
  • 两边都能被16整除
  • 比例 ≤ 3:1
  • 总像素 0.65–8.3MP

画质说明

画质说明适用场景
low草图/批量生成快速预览、多次迭代
medium日常普通使用
high终稿/精细文字最终输出、包含文字的图像
auto默认由模型决定

输出格式说明

格式说明适用场景
png无压缩,透明背景需要透明背景、保留最佳画质
jpeg有压缩照片、存储空间敏感
webp现代格式Web使用、平衡画质与大小

注意:b64_json字段是纯base64,不含 data:image/...;base64, 前缀。客户端需要:

  • 写文件:base64.b64decode(b64_str) → 写入磁盘
  • 浏览器渲染:自行拼前缀 data:image/png;base64, + b64

注意事项

  • API密钥必须设置,可通过环境变量或命令行参数提供
  • 图片生成时间:约120-150秒,high + 2K/4K 复杂场景可能需要更长时间
  • 编辑图片时,使用multipart/form-data上传参考图
  • 确保输出目录有写入权限
  • 按token计费(非按张)

API Key设置与获取

如何获取API Key

如果你还没有API密钥,请前往 https://api.apiyi.com 注册账号并申请API Key。

获取步骤:

  1. 访问 https://api.apiyi.com
  2. 注册/登录你的账号
  3. 在控制台中创建API密钥
  4. 复制密钥并设置环境变量或在命令行中使用

设置API Key

脚本按以下顺序查找API密钥:

  1. --api-key 命令行参数(临时使用)
  2. APIYI_API_KEY 环境变量(推荐)

设置环境变量(推荐):

# Linux/Mac
export APIYI_API_KEY="your-api-key-here"

# Windows CMD
我的电脑高级设置中设置环境变量或者执行set APIYI_API_KEY=your-api-key-here

# Windows PowerShell
在我的电脑中设置环境变量:$env:APIYI_API_KEY="your-api-key-here"

命令行参数方式(临时):

python scripts/generate_image.py -p "一只猫" -k "your-api-key-here"

API端点说明

文生图端点:POST /v1/images/generations

文生图端点,使用JSON格式请求。

图生图端点:POST /v1/images/edits

图生图端点,使用multipart/form-data格式请求。上传参考图(最多5张)+ 指令进行单图改图、多图融合。

参考图顺序有意义,prompt中可用"图1/图2/图3"指代。

模型信息

  • 模型名:gpt-image-2
  • 出图速度:约 120-150秒(4K复杂场景可能需要更长时间)
  • 输出分辨率:1024x1024 / 1536x1024 / 1024x1536 / 2048x2048 / 2048x1152 / 3840x2160 / 2160x3840 或自定义
  • 默认响应格式:b64_json(纯base64,无前缀)
  • 画质档位:low / medium / high / auto
  • 输出格式:png / jpeg / webp
  • 支持能力:文生图、单图编辑、多图融合
  • 计费方式:按token计费

gpt-image-2(官转)vs gpt-image-2-all(官逆)对比

特性gpt-image-2gpt-image-2-all
性质官方正式版官方逆向版
计费按token统一$0.03/张
端点/v1/images/generations, /v1/images/edits/v1/chat/completions
上传参考图multipart form-database64 data URL
下载图片b64_json(纯base64)url或b64_json(带前缀)
多图融合image[]数组最多5张chat多个image_url
尺寸控制显式size参数prompt描述
速度约120-150秒约60-300秒

作者介绍

Comments

Loading comments...