Files
2026-07-22 01:12:03 +08:00

45 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# gen-image · 生图 Skill
通过大模型中转站,直接调用 OpenAI 图片接口生图。文生图 / 图生图 / 局部重绘 / 透明背景,零第三方依赖。
## 快速开始
```bash
# 1. 文生图
./gen.sh "a cozy cabin in snowy mountains, golden hour, cinematic" \
--size 1536x1024 --quality high
# 2. 图生图 / 编辑
./gen.sh "把背景换成星空" --edit input.png
# 3. 局部重绘(mask 透明处为重绘区域)
./gen.sh "戴上一顶红帽子" --edit input.png --mask mask.png
```
图片保存到 `output/`,脚本打印完整路径。
## 配置(每人用自己的中转站账号)
**TD工具箱用户(推荐):** 在工具箱「中转」里,给一个支持 OpenAI 图片接口的中转分组勾选 **☑ 在 Codex 中用于生图** 并保存——工具箱自动把该分组的 base_url+密钥写进本技能的 `.env`,无需手动配置。重装技能后工具箱会自动重写。
**手动方式(无工具箱):** `cp .env.example .env`,填三项:
| 变量 | 说明 |
|------|------|
| `IMAGE_API_BASE_URL` | 你的中转站基址,如 `https://api.xxx.com`(自动补 `/v1/images/...`) |
| `IMAGE_API_KEY` | 你的中转站 API Key |
| `IMAGE_MODEL` | 默认模型,默认 `gpt-image-2`,可用 `--model` 覆盖 |
读取优先级:**环境变量 > skill 目录 `.env`**。CI/临时场景可直接 `export IMAGE_API_KEY=...`。
## 参数
`--size` `--n` `--quality` `--background transparent` `--edit`(可多次) `--mask` `--model` `--output`
详见 `python3 scripts/gen_image.py --help` 与 `SKILL.md`。
## 安全
- 凭证存在本技能目录的 `.env`(工具箱写入时权限 600),已被 `.gitignore` 忽略,不进 git。
- 分发包只含 `.env.example` 模板,绝不含真实 Key。
- 切勿把 API Key 写进代码、日志或对话。