imagine-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseimagine CLI
imagine CLI
imagine-p "..."-i reference.pngimagine-p "..."-i reference.pngWhen to use
适用场景
Use this skill whenever the user:
- Mentions the command, any of its flags, providers (gemini, vertex, openai), or model aliases (
imagine,gpt-image-2,pro,flash, etc.)1.5 - Wants to generate or edit images from the command line
- Is setting up the tool for the first time
- Hits an error they don't understand (most imagine errors are self-explanatory but the full list + fixes live in references/troubleshooting.md)
- Asks which provider to pick for a task
- References sizes (,
1K,2K,4K,1024x1024, etc.)3840x2160
当用户出现以下情况时,适用本技能:
- 提及 命令、其任意参数、提供商(gemini、vertex、openai)或模型别名(
imagine、gpt-image-2、pro、flash等)1.5 - 希望通过命令行生成或编辑图像
- 首次设置该工具
- 遇到无法理解的错误(多数imagine错误自带说明,但完整错误列表及修复方案请查看 references/troubleshooting.md)
- 询问针对某项任务应选择哪个提供商
- 提及图像尺寸(、
1K、2K、4K、1024x1024等)3840x2160
Workflow
工作流程
Always walk these three pre-flight steps before running an imagine command.
在运行imagine命令前,务必完成以下三项预检查步骤。
Step 1 — Is imagine installed?
步骤1 — 是否已安装imagine?
bash
command -v imagine || echo NOT_INSTALLEDIf , decide the install method automatically — don't prompt the user to pick.
NOT_INSTALLEDDecision: check for Go first. If the user has Go, install from source (faster, keeps the binary up-to-date with on re-runs). Otherwise fall back to the pre-built binary.
go install …@latestbash
if command -v go >/dev/null 2>&1; then
go install github.com/AhmedAburady/imagine-cli/cmd/imagine@latest
else
# Detect platform, pick the matching release asset
case "$(uname -s)-$(uname -m)" in
Darwin-arm64) ASSET=imagine-darwin-arm64 ;;
Darwin-x86_64) ASSET=imagine-darwin-amd64 ;;
Linux-x86_64) ASSET=imagine-linux-amd64 ;;
Linux-aarch64|Linux-arm64) ASSET=imagine-linux-arm64 ;;
*) echo "Unsupported platform — download manually from https://github.com/AhmedAburady/imagine-cli/releases/latest"; exit 1 ;;
esac
curl -L -o imagine "https://github.com/AhmedAburady/imagine-cli/releases/latest/download/$ASSET"
chmod +x imagine
sudo mv imagine /usr/local/bin/imagine
fiAfter install, verify:
bash
imagine --versionWindows users: download (or ) from the releases page, rename to , and place on .
imagine-windows-amd64.exe-arm64.exeimagine.exe%PATH%bash
command -v imagine || echo NOT_INSTALLED如果返回 ,请自动选择安装方式——不要让用户手动选择。
NOT_INSTALLED决策逻辑: 先检查是否安装Go。若已安装Go,则从源码安装(速度更快,重新运行 即可保持二进制文件更新)。否则使用预编译二进制文件。
go install …@latestbash
if command -v go >/dev/null 2>&1; then
go install github.com/AhmedAburady/imagine-cli/cmd/imagine@latest
else
# 检测平台,选择匹配的发布资源
case "$(uname -s)-$(uname -m)" in
Darwin-arm64) ASSET=imagine-darwin-arm64 ;;
Darwin-x86_64) ASSET=imagine-darwin-amd64 ;;
Linux-x86_64) ASSET=imagine-linux-amd64 ;;
Linux-aarch64|Linux-arm64) ASSET=imagine-linux-arm64 ;;
*) echo "不支持的平台——请从https://github.com/AhmedAburady/imagine-cli/releases/latest手动下载"; exit 1 ;;
esac
curl -L -o imagine "https://github.com/AhmedAburady/imagine-cli/releases/latest/download/$ASSET"
chmod +x imagine
sudo mv imagine /usr/local/bin/imagine
fi安装完成后,验证:
bash
imagine --versionWindows用户:从发布页面下载 (或 ),重命名为 ,并放置在 路径下。
imagine-windows-amd64.exe-arm64.exeimagine.exe%PATH%Step 2 — Does the config file exist with at least one provider?
步骤2 — 配置文件是否存在且至少包含一个提供商?
bash
cat ~/.config/imagine/config.yaml 2>/dev/null \
|| cat ~/.config/imagine/config.yml 2>/dev/null \
|| echo NO_CONFIGWindows path: .
%AppData%\imagine\config.yamlIf missing or the block is empty, walk the user through creating one. Full schema and per-provider credential setup in references/config.md. A ready-to-copy template sits at assets/config.example.yaml.
providers:Minimal Gemini-only example:
yaml
default_provider: gemini
providers:
gemini:
api_key: AIza-paste-key-herebash
cat ~/.config/imagine/config.yaml 2>/dev/null \
|| cat ~/.config/imagine/config.yml 2>/dev/null \
|| echo NO_CONFIGWindows路径:。
%AppData%\imagine\config.yaml如果配置文件缺失或 块为空,引导用户创建配置文件。完整配置 schema 及各提供商凭证设置请查看 references/config.md。可直接复制的模板位于 assets/config.example.yaml。
providers:仅配置Gemini的最简示例:
yaml
default_provider: gemini
providers:
gemini:
api_key: AIza-paste-key-hereStep 3 — Resolve the active provider
步骤3 — 确定当前激活的提供商
Every invocation runs under one active provider. Precedence:
imagine--provider <name> (CLI flag — highest)
↓
default_provider (config.yaml)
↓
first under providers: (alphabetical)
↓
errorimagine providers show[active][default]每次调用 都会基于一个激活的提供商运行,优先级顺序如下:
imagine--provider <名称> (CLI参数——优先级最高)
↓
default_provider (config.yaml中的配置)
↓
providers下的第一个提供商 (按字母顺序)
↓
报错imagine providers show[active][default]Common flags (every provider)
通用参数(所有提供商适用)
| Flag | Long | Purpose |
|---|---|---|
| | Prompt (required). Also accepts a file path. |
| | Output folder (default |
| | Output filename. Extension ( |
| | 1-20 images |
| | Reference image/folder, repeatable. Flips to edit mode. |
| | Use input filename for output (single |
| Per-invocation override |
| 短选项 | 长选项 | 用途 |
|---|---|---|
| | 提示词(必填)。也支持传入文件路径。 |
| | 输出文件夹(默认当前目录 |
| | 输出文件名。扩展名( |
| | 生成1-20张图像 |
| | 参考图像/文件夹,可重复使用。触发编辑模式。 |
| | 使用输入文件名作为输出文件名(仅适用于单个 |
| 单次调用时覆盖默认提供商 |
Provider-specific flags
提供商专属参数
Flags that don't belong to the active provider are rejected with a clear error. Deep detail per provider:
- Gemini / Vertex → references/gemini.md. Flags: ,
-m pro/flash,-s 1K/2K/4K,-a aspect-ratio,-g grounding(flash only),-t thinking(gemini flash only).-I image-search - OpenAI → references/openai.md. Flags: ,
-m gpt-image-2 family,-s shorthand/raw WxH,-q quality,--compression,--moderation. Includes the full size matrix and edit-mode size restriction.--background
When the user is unsure which provider to pick:
- Photorealism, text rendering, intricate prompts → OpenAI
gpt-image-2 - Fast iteration, Google ecosystem, live-search grounding → Gemini or Vertex
- GCP-native auth / enterprise quotas → Vertex
不属于当前激活提供商的参数会被拒绝并返回清晰错误。各提供商详细说明:
- Gemini / Vertex → references/gemini.md。参数:、
-m pro/flash、-s 1K/2K/4K、-a aspect-ratio、-g grounding(仅flash支持)、-t thinking(仅gemini flash支持)。-I image-search - OpenAI → references/openai.md。参数:、
-m gpt-image-2 family、-s shorthand/raw WxH、-q quality、--compression、--moderation。包含完整尺寸矩阵及编辑模式下的尺寸限制。--background
当用户不确定选择哪个提供商时:
- 追求照片级真实感、文字渲染、复杂提示词 → OpenAI
gpt-image-2 - 快速迭代、Google生态、实时搜索 grounding → Gemini 或 Vertex
- GCP原生认证 / 企业配额 → Vertex
Describe subcommand
Describe子命令
bash
imagine describe -i photo.jpg # plain text
imagine describe -i ./styles/ -json -o style.json
imagine describe -i photo.jpg -vertex # Vertex backendGemini/Vertex only — describe doesn't support OpenAI. Needs either or configured. If the user has only OpenAI configured, describe prints friendly setup instructions (with for Vertex) and exits.
providers.gemini.api_keyproviders.vertex.provider_options.gcp_projectgcloud auth application-default loginbash
imagine describe -i photo.jpg # 纯文本描述
imagine describe -i ./styles/ -json -o style.json
imagine describe -i photo.jpg -vertex # 使用Vertex后端仅Gemini/Vertex支持 — describe子命令不支持OpenAI。需要配置 或 。如果用户仅配置了OpenAI,describe命令会打印友好的设置指引(包括Vertex的 命令)并退出。
providers.gemini.api_keyproviders.vertex.provider_options.gcp_projectgcloud auth application-default loginExamples
示例
bash
undefinedbash
undefinedGenerate (active provider from config)
生成图像(使用配置中的激活提供商)
imagine -p "a sunset over mountains"
imagine -p "山间日落"
Batch with size + aspect (Gemini/Vertex)
批量生成并指定尺寸和宽高比(Gemini/Vertex)
imagine -p "cityscape" -n 3 -s 2K -a 16:9 -o ./city
imagine -p "城市景观" -n 3 -s 2K -a 16:9 -o ./city
OpenAI — fast draft
OpenAI — 快速生成草稿
imagine -p "logo idea" --provider openai -q low
imagine -p "logo创意" --provider openai -q low
OpenAI — 4K hero banner as JPEG
OpenAI — 生成4K英雄横幅JPEG图
imagine -p "hero banner" --provider openai -s 3840x2160 -q high -f hero.jpg
imagine -p "英雄横幅" --provider openai -s 3840x2160 -q high -f hero.jpg
Edit, keep input filename
编辑图像,保留输入文件名
imagine -p "add rain" -i photo.png -r
imagine -p "添加雨景" -i photo.png -r
Multi-reference edit (OpenAI supports up to 16 refs/call)
多参考图编辑(OpenAI单次调用最多支持16张参考图)
imagine -p "gift basket of these" --provider openai
-i lotion.png -i candle.png -i soap.png
-i lotion.png -i candle.png -i soap.png
imagine -p "将这些物品组成礼品篮" --provider openai
-i lotion.png -i candle.png -i soap.png
-i lotion.png -i candle.png -i soap.png
Vertex — same flags as Gemini, different auth
Vertex — 参数与Gemini相同,认证方式不同
imagine -p "a cat" --provider vertex -n 3
For more, run `imagine --help` — provider-aware help surfaces the active provider's flags and a tailored EXAMPLES block.imagine -p "一只猫" --provider vertex -n 3
更多示例请运行 `imagine --help` — 提供商感知型帮助会显示当前激活提供商的参数及定制化的示例区块。Anti-patterns — do NOT do these
反模式——请勿执行以下操作
- Never suggest ,
GEMINI_API_KEY, or any env var for credentials. imagine does not read env vars. Config file only.OPENAI_API_KEY - Never suggest — those commands don't exist. Users edit
imagine config set-*directly.config.yaml - Never use ,
-ar,-isas single-dash flags. They're-vertex,--aspect-ratio,--image-search. (Describe keeps its own legacy--provider vertexflag — the exception.)-vertex - Never combine with
--background transparent. Unsupported — usegpt-image-2.-m 1.5 - Never combine with
-f— mutually exclusive.-r - Never suggest for the describe subcommand. Describe is Gemini/Vertex only.
--provider openai
- 切勿建议使用 、
GEMINI_API_KEY或任何环境变量存储凭证。imagine 不读取环境变量,仅支持配置文件。OPENAI_API_KEY - 切勿建议使用 命令——这些命令不存在。用户需直接编辑
imagine config set-*。config.yaml - 切勿将 、
--aspect-ratio、--image-search写成单短横线形式(如--provider vertex、-ar、-is)。(Describe子命令保留了自己的旧版-vertex参数——此为例外情况。)-vertex - 切勿将 与
--background transparent组合使用——该组合不支持,请使用gpt-image-2。-m 1.5 - 切勿同时使用 和
-f——二者互斥。-r - 切勿建议对describe子命令使用 ——Describe仅支持Gemini/Vertex。
--provider openai
Troubleshooting
故障排查
When imagine errors, read references/troubleshooting.md before guessing. Covers every error message the CLI can produce with its specific fix.
当imagine报错时,请先查看 references/troubleshooting.md 再尝试排查。该文档涵盖了CLI可能产生的所有错误消息及其对应的修复方案。