ZJU-REAL/Easel / skills/builtin/ai-image-gen
ai-image-gen
Verified通用 AI 生图:文生图 / 图生图 / 图像变体。当用户说 AI 生图、AI 画图、文生图、图生图、生成图片、生成配图、图像生成、AI 出图、AI 作图、换图、改图、图像编辑、给我画一张、生成一张图 时使用。支持 OpenAI 兼容 API 与 apimart 异步 API,用户自备 API key。
| File | Kind | Size |
|---|---|---|
| EASEL-META.md | markdown | 2.1 KB |
| SKILL.md | skill md | 5.0 KB |
EASEL-META.md
View on GitHub# Easel SKILL 元数据
| 字段 | 值 |
|------|-----|
| **SKILL 名称** | ai-image-gen |
| **所属层** | produce |
| **来源** | Easel 自研 |
| **参考** | OpenAI Images API(/images/generations、/images/edits、/images/variations);apimart.ai 异步图片任务 API |
| **功能描述** | 通用 AI 生图:文生图 / 图生图(图像编辑)/ 图像变体,OpenAI 兼容同步 + apimart 异步双模式自动检测 |
| **核心脚本** | `skills/shared/scripts/ai_image.py`(纯标准库 urllib/http,无第三方依赖) |
| **子命令** | text2img / img2img / variations / check |
| **配置** | `.env` 三项:IMG_BASE_URL / IMG_MODEL / IMG_API_KEY(含 OPENAI_* 等别名),用户自备 key |
| **profile_aware** | true |
| **自包含** | 需用户配置图像生成 API(OpenAI 兼容 或 apimart) |
> 创建时间: 2026-07-23
> 用途: 补齐 produce 层通用 AI 生图能力(区别于电商专用 ecom-details-image 与 HTML 渲染类 card-*)
## 设计说明
- **复用**:脚本复用了项目已验证的 `ecom-details-image/scripts/generate_image.py` 的核心约定与逻辑——
env 别名解析(IMG_* + OPENAI_* 别名)、就近 `.env` 加载、base_url 自动检测同步/异步、
apimart 异步提交→轮询 `/tasks/<id>`→下载、b64_json / URL 结果落盘、统一中文 `fail()` 错误处理。
- **新增**:argparse 子命令(text2img/img2img/variations/check);
`check` 离线校验(读 env、脱敏打印、报模式、缺项给示例,不发任何请求);
OpenAI `/images/edits` 与 `/images/variations` 的纯标准库 multipart 上传;
`.env` 宽松解析(跳过非 KEY=value 行并告警,避免 check 因用户 .env 杂行崩溃)。
## 离线验证(无真实 key)
- `python skills/shared/scripts/ai_image.py --help` 及各子命令 `-h`:正常
- `ai_image.py check`:正常打印配置状态,缺项退出码 2、不崩溃
- 缺 key 时 `text2img`:输出友好中文错误,无 traceback
- `ast.parse` 通过
- 未使用真实 key 做端到端联网测试(用户自备 key 后可实际出图)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |