baoyu-image-gen について
baoyu-image-gen は、AI SDK 経由で OpenAI と Google の画像モデルを使う画像生成スキルです。コマンドラインでの生成や編集に適し、参照画像や出力設定、プロバイダー選択に対応します。
主な機能
- 01OpenAI と Google の画像モデルを利用
- 02ファイルからプロンプトを読み込み
- 03縦横比、サイズ、画質を設定
- 04参照画像で編集やスタイル統合
- 05複数画像の生成を指定
- 06テキストまたは JSON で出力
活用シーン
- 01カバー画像やイラストの生成
- 02SNS 用の正方形画像の作成
- 03画像の背景やスタイルの変更
- 04プロンプトファイルから場面画像を生成
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ smallnest/ langgraphgo --skill baoyu-image-genインストール後、Claude Code で/baoyu-image-genを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
package-lock.jsonpackage.jsonscripts/main.ts詳細
画像生成(AI SDK)
AI SDK を使用した公式 API ベースの画像生成です。OpenAI(DALL-E、GPT Image)と Google(Imagen、Gemini マルチモーダル)に対応しています。
スクリプトディレクトリ
重要:すべてのスクリプトは、このスキルの scripts/ サブディレクトリにあります。
エージェントの実行手順:
- この SKILL.md ファイルのディレクトリパスを
SKILL_DIRとして特定します - スクリプトのパス =
${SKILL_DIR}/scripts/<script-name>.ts - このドキュメント内のすべての
${SKILL_DIR}を実際のパスに置き換えます
スクリプトのリファレンス:
| スクリプト | 目的 |
|---|---|
scripts/main.ts | 画像生成の CLI エントリーポイント |
クイックスタート
# Basic generation (auto-detect provider)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png
# With aspect ratio
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A landscape" --image landscape.png --ar 16:9
# High quality (2k)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality 2k
# Specific provider
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --provider openai
# From prompt files
npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image out.png
# With reference images (Google multimodal only)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make blue" --image out.png --ref source.png
コマンド
基本的な画像生成
# Generate with prompt
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A sunset over mountains" --image sunset.png
# Shorthand
npx -y bun ${SKILL_DIR}/scripts/main.ts -p "A cute robot" --image robot.png
アスペクト比
# Common ratios: 1:1, 16:9, 9:16, 4:3, 3:4, 2.35:1
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A portrait" --image portrait.png --ar 3:4
# Or specify exact size
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Banner" --image banner.png --size 1792x1024
参照画像(Google マルチモーダル)
# Image editing with reference
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make it blue" --image blue.png --ref original.png
# Multiple references
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Combine these styles" --image out.png --ref a.png b.png
品質プリセット
# Normal quality (default)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality normal
# High quality (2k resolution)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality 2k
出力形式
# Plain output (prints saved path)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png
# JSON output
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --json
オプション
| オプション | 説明 |
|---|---|
--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 | 品質プリセット(デフォルト:normal) |
--ref <files...> | 参照画像(Google マルチモーダルのみ) |
--n <count> | 画像の枚数 |
--json | JSON 出力 |
--help, -h | ヘルプを表示 |
環境変数
| 変数 | 説明 | デフォルト |
|---|---|---|
OPENAI_API_KEY | OpenAI API キー | - |
GOOGLE_API_KEY | Google API キー | - |
OPENAI_IMAGE_MODEL | OpenAI モデル | gpt-image-1.5 |
GOOGLE_IMAGE_MODEL | Google モデル | gemini-3-pro-image-preview |
OPENAI_BASE_URL | カスタム OpenAI エンドポイント | - |
GOOGLE_BASE_URL | カスタム Google エンドポイント | - |
読み込みの優先順位:CLI 引数 > process.env > <cwd>/.baoyu-skills/.env > ~/.baoyu-skills/.env
プロバイダーとモデルの選択方法
自動選択
--providerが指定されている場合 → 指定されたプロバイダーを使用します- API キーが1つだけ使用可能な場合 → そのプロバイダーを使用します
- 両方使用可能な場合 → デフォルトで Google を使用します(マルチモーダル LLM のほうが汎用性に優れています)
モデルの種類に応じた API の選択
| モデルのカテゴリ | API 関数 | モデルの例 |
|---|---|---|
| Google マルチモーダル | generateText | gemini-2.0-flash-exp-image-generation |
| Google Imagen | experimental_generateImage | imagen-3.0-generate-002 |
| OpenAI | experimental_generateImage | gpt-image-1、dall-e-3 |
利用可能なモデル
Google:
gemini-3-pro-image-preview- デフォルト、マルチモーダル生成gemini-2.0-flash-exp-image-generation- Gemini 2.0 Flashimagen-3.0-generate-002- Imagen 3
OpenAI:
gpt-image-1.5- デフォルト、GPT Image 1.5gpt-image-1- GPT Image 1dall-e-3- DALL-E 3
品質プリセット
| プリセット | OpenAI | 用途 | |
|---|---|---|---|
normal | 1024x1024 | デフォルト | カバー、イラスト |
2k | 2048x2048 | プロンプトに「2048px」 | インフォグラフィック、スライド |
アスペクト比の処理
- マルチモーダル LLM:プロンプトに埋め込まれます(例:
"... aspect ratio 16:9") - 画像専用モデル:
aspectRatioまたはsizeパラメーターを使用します - 一般的な比率:1:1、16:9、9:16、4:3、3:4、2.35:1
例
カバー画像を生成する
npx -y bun ${SKILL_DIR}/scripts/main.ts \
--prompt "A minimalist tech illustration with blue gradients" \
--image cover.png --ar 2.35:1 --quality 2k
ソーシャルメディアの投稿を生成する
npx -y bun ${SKILL_DIR}/scripts/main.ts \
--prompt "Instagram post about coffee" \
--image post.png --ar 1:1
参照画像を使って画像を編集する
npx -y bun ${SKILL_DIR}/scripts/main.ts \
--prompt "Change the background to sunset" \
--image edited.png --ref original.png --provider google
プロンプトファイルから一括生成する
# Create prompt file with detailed instructions
npx -y bun ${SKILL_DIR}/scripts/main.ts \
--promptfiles style-guide.md scene-description.md \
--image scene.png
エラー処理
- API キーがない場合:設定手順を含む明確なエラーが表示されます
- 生成に失敗した場合:自動で1回再試行し、その後エラーになります
- アスペクト比が無効な場合:警告を表示し、デフォルト値で続行します
- 画像専用モデルで参照画像を使用した場合:警告を表示し、参照画像を無視します
拡張機能のサポート
EXTEND.md によるカスタム設定。
確認するパス(優先順位順):
.baoyu-skills/baoyu-image-gen/EXTEND.md(プロジェクト)~/.baoyu-skills/baoyu-image-gen/EXTEND.md(ユーザー)
見つかった場合は、ワークフローの前に読み込みます。拡張内容はデフォルト設定より優先されます。
コメント
Markdown 対応