baoyu-image-gen

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Image Generation (AI SDK)

图片生成(AI SDK)

Official API-based image generation. Supports OpenAI and Google providers.
基于官方API的图片生成工具,支持OpenAI和Google提供商。

Script Directory

脚本目录

Agent Execution:
  1. SKILL_DIR
    = this SKILL.md file's directory
  2. Script path =
    ${SKILL_DIR}/scripts/main.ts
Agent执行步骤:
  1. SKILL_DIR
    = 本SKILL.md文件所在目录
  2. 脚本路径 =
    ${SKILL_DIR}/scripts/main.ts

Preferences (EXTEND.md)

偏好设置(EXTEND.md)

Use Bash to check EXTEND.md existence (priority order):
bash
undefined
使用Bash检查EXTEND.md的存在性(优先级顺序):
bash
undefined

Check project-level first

优先检查项目级目录

test -f .baoyu-skills/baoyu-image-gen/EXTEND.md && echo "project"
test -f .baoyu-skills/baoyu-image-gen/EXTEND.md && echo "project"

Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)

然后检查用户级目录(跨平台:$HOME适用于macOS/Linux/WSL)

test -f "$HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md" && echo "user"

┌──────────────────────────────────────────────────┬───────────────────┐
│                       Path                       │     Location      │
├──────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-image-gen/EXTEND.md          │ Project directory │
├──────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md    │ User home         │
└──────────────────────────────────────────────────┴───────────────────┘

┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│  Result   │                                  Action                                   │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Found     │ Read, parse, apply settings                                               │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Not found │ Use defaults                                                              │
└───────────┴───────────────────────────────────────────────────────────────────────────┘

**EXTEND.md Supports**: Default provider | Default quality | Default aspect ratio
test -f "$HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md" && echo "user"

┌──────────────────────────────────────────────────┬───────────────────┐
│                       路径                       │        位置        │
├──────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-image-gen/EXTEND.md          │    项目目录        │
├──────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md    │    用户主目录      │
└──────────────────────────────────────────────────┴───────────────────┘

┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│   结果    │                                  操作                                   │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│   找到    │ 读取、解析并应用设置                                                     │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│   未找到  │ 使用默认设置                                                              │
└───────────┴───────────────────────────────────────────────────────────────────────────┘

**EXTEND.md支持配置**:默认提供商 | 默认质量 | 默认宽高比

Usage

使用方法

bash
undefined
bash
undefined

Basic

基础用法

npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一只猫" --image cat.png

With aspect ratio

指定宽高比

npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A landscape" --image out.png --ar 16:9
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一幅风景画" --image out.png --ar 16:9

High quality

高质量生成

npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image out.png --quality 2k
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一只猫" --image out.png --quality 2k

From prompt files

从文件读取提示词

npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image out.png
npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image out.png

With reference images (Google multimodal only)

使用参考图片(仅Google多模态模型支持)

npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make blue" --image out.png --ref source.png
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "改成蓝色" --image out.png --ref source.png

Specific provider

指定提供商

npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image out.png --provider openai
undefined
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一只猫" --image out.png --provider openai
undefined

Options

选项参数

OptionDescription
--prompt <text>
,
-p
Prompt text
--promptfiles <files...>
Read prompt from files (concatenated)
--image <path>
Output image path (required)
--provider google|openai
Force provider (default: google)
--model <id>
,
-m
Model ID
--ar <ratio>
Aspect ratio (e.g.,
16:9
,
1:1
,
4:3
)
--size <WxH>
Size (e.g.,
1024x1024
)
--quality normal|2k
Quality preset (default: 2k)
--imageSize 1K|2K|4K
Image size for Google (default: from quality)
--ref <files...>
Reference images (Google multimodal only)
--n <count>
Number of images
--json
JSON output
选项参数说明
--prompt <text>
,
-p
提示文本
--promptfiles <files...>
从文件读取提示词(多文件内容会拼接)
--image <path>
输出图片路径(必填)
--provider google|openai
强制指定提供商(默认:google)
--model <id>
,
-m
模型ID
--ar <ratio>
宽高比(例如:
16:9
,
1:1
,
4:3
--size <WxH>
尺寸(例如:
1024x1024
--quality normal|2k
质量预设(默认:2k)
--imageSize 1K|2K|4K
Google模型的图片尺寸(默认:跟随质量预设)
--ref <files...>
参考图片(仅Google多模态模型支持)
--n <count>
生成图片数量
--json
输出JSON格式结果

Environment Variables

环境变量

VariableDescription
OPENAI_API_KEY
OpenAI API key
GOOGLE_API_KEY
Google API key
OPENAI_IMAGE_MODEL
OpenAI model override
GOOGLE_IMAGE_MODEL
Google model override
OPENAI_BASE_URL
Custom OpenAI endpoint
GOOGLE_BASE_URL
Custom Google endpoint
Load Priority: CLI args > env vars >
<cwd>/.baoyu-skills/.env
>
~/.baoyu-skills/.env
变量名说明
OPENAI_API_KEY
OpenAI API密钥
GOOGLE_API_KEY
Google API密钥
OPENAI_IMAGE_MODEL
覆盖OpenAI默认模型
GOOGLE_IMAGE_MODEL
覆盖Google默认模型
OPENAI_BASE_URL
自定义OpenAI端点地址
GOOGLE_BASE_URL
自定义Google端点地址
加载优先级:命令行参数 > 环境变量 >
<cwd>/.baoyu-skills/.env
>
~/.baoyu-skills/.env

Provider Selection

提供商选择逻辑

  1. --provider
    specified → use it
  2. Only one API key available → use that provider
  3. Both available → default to Google
  1. 指定
    --provider
    参数 → 使用该提供商
  2. 仅存在一个API密钥 → 使用对应提供商
  3. 两个API密钥都存在 → 默认使用Google

Quality Presets

质量预设

PresetGoogle imageSizeOpenAI SizeUse Case
normal
1K1024pxQuick previews
2k
(default)
2K2048pxCovers, illustrations, infographics
Google imageSize: Can be overridden with
--imageSize 1K|2K|4K
预设值Google imageSizeOpenAI 尺寸使用场景
normal
1K1024px快速预览
2k
(默认)
2K2048px封面图、插画、信息图
Google imageSize:可通过
--imageSize 1K|2K|4K
参数覆盖

Aspect Ratios

支持的宽高比

Supported:
1:1
,
16:9
,
9:16
,
4:3
,
3:4
,
2.35:1
  • Google multimodal: uses
    imageConfig.aspectRatio
  • Google Imagen: uses
    aspectRatio
    parameter
  • OpenAI: maps to closest supported size
支持:
1:1
,
16:9
,
9:16
,
4:3
,
3:4
,
2.35:1
  • Google多模态模型:使用
    imageConfig.aspectRatio
    参数
  • Google Imagen模型:使用
    aspectRatio
    参数
  • OpenAI:自动映射到最接近的支持尺寸

Error Handling

错误处理

  • Missing API key → error with setup instructions
  • Generation failure → auto-retry once
  • Invalid aspect ratio → warning, proceed with default
  • Reference images with non-multimodal model → warning, ignore refs
  • 缺少API密钥 → 抛出错误并提供设置指引
  • 生成失败 → 自动重试一次
  • 无效宽高比 → 发出警告,使用默认值继续执行
  • 非多模态模型使用参考图片 → 发出警告,忽略参考图片

Extension Support

扩展支持

Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
可通过EXTEND.md进行自定义配置。详见偏好设置章节的路径说明和支持的配置项。