AI Image Generation and Editing · dby-image
Image generation goes through
— don't hand-craft curl requests.
How to Use
Run from the user's working directory, using the script's full path — images will be saved to the current directory, not inside the skill package.
Replace
below with the actual path to this skill's
.
Requests are sent by
; only read
dby-gateway/references/protocol.md
if you bypass the script and build requests yourself
(authentication, how to get keys, envelope and error codes are all there).
bash
export DOUBAOYA_API_KEY="dyh_你的密钥" # 绝不打印、不写文件、不回显给用户
GEN=~/.claude/skills/dby-image/scripts/gen.mjs # 按实际安装位置改
# 文生图。比例写进 prompt(size 参数无效,见下)
node "$GEN" "一只戴围巾的黄色小鸭子站在雪地里,卡通插画风。宽幅横版,16:9 比例。" --out duck.jpg
# 改图。--ref 可以是本机文件路径、公网 URL 或 data: URI,写几次就是几张,最多 3 张
node "$GEN" "只把围巾换成蓝色,其余全部保持不变:鸭子造型、姿势、雪地场景、构图都不要动。" \
--ref ./duck.jpg --out duck2.png
# 对账:拉生产实时契约,核本包的参数认知有没有过期(免费,不出图)
node "$GEN" --describe
For details only (price / input contract / output samples) without comparison:
node "$SKILL_DIR/scripts/dby.mjs" api describe gpt-image-gen
.
is relative to the current working directory; if omitted, writes to
in the current directory.
Without , the default tier is used; the three tiers have different prices (see
for live prices). To choose, see
— "Which model to choose" — it also explains
why you can't promise users that "switching will definitely improve fidelity".
stdout only contains the file path (can be piped or captured directly); progress and actual dimensions go to stderr:
✅ 129KB 实测 1672x941 比例 1.777 耗时 37s
Before calling, tell the user: this step takes a while, usually 1–2 minutes, up to 4 minutes, don't interrupt midway.
🔴 Four Red Lines
1. Don't retry after failure
Server-side timeout will refund, client-side early abort will not — the request will still complete and still be charged; retrying = paying twice for the same image.
Same for insufficient credits (402) and capability unavailable (503).
On failure, stop and honestly tell the user: this attempt may have been charged and the image may already be generated; let the user decide whether to try again.
2. Facts in images must not be fabricated either
When it involves brand or product facts — names, primary colors, product names, claims, specific numbers —
only two sources are allowed: the user's IP profile, or provided by the user on the spot. If unavailable, ask.
3. Style belongs to the user, not the assistant
If the user hasn't specified a style,
don't add one for them (flat illustration, solid background, no text — all count); in practice, bare prompts produce richer images.
Want to give suggestions? Offer two or three options from
and let the user choose.
⚠️ The upstream adds its own. Tested 2026-09: it rewrites the prompt before generating, and automatically appends
exclusions like "no text, no watermark, no logo". This isn't from us, but the user sees the result —
so ① don't stack another layer of your own constraints, ② if the user wants text in the image and it doesn't appear, honestly explain this is upstream behavior,
and switch to post-processing overlay — don't repeatedly resend the same prompt pretending to bypass it (each round costs money).
4. Aspect ratio can only be written into the prompt
The
parameter is
completely ignored by upstream — confirmed again after the 2026-09 upgrade to gpt-image-2.5:
request
, actual output 1672×941 / 1731×909, ratio all comes from the "16:9" in the prompt.
Write the ratio directly in the description: "wide horizontal, 16:9 ratio" → actual 1672×941. For what ratio to use on each platform, check
— "Aspect Ratio Quick Reference" (WeChat cover: 16:9, main subject inside center square — WeChat crops at 2.35:1 and center 1:1).
For precise pixels you can only crop yourself after getting the image. The script prints actual dimensions every time —
check them once.
After Image Generation: Acceptance Check (required, free)
Read back the just-saved file, check it item by item against this request before delivering.
The checklist is generated from this request (countable elements the user explicitly named, named text, objective constraints added by the assistant),
only judge falsifiable things, not aesthetics, zero automatic regeneration.
WeChat cover has one extra free step:
node scripts/wechat-crops.mjs ./cover.jpg
outputs message-list 2.35:1, forward-card center 1:1,
and a 360px thumbnail; read them back and verify "subject and title are complete in 1:1, title is readable in thumbnail" — WeChat only accepts one cover,
the 1:1 is cropped out, not a separate image.
How:
references/visual-review.md
How to Write Prompts
Default starting point is to send the user's words as-is, only adding objective constraints unavoidable in this scenario (ratio, crop safety zones).
When unsatisfied with the output, add only one dimension at a time — adding three at once makes it impossible to tell which didn't work, and each round costs money.
| What you need | Where to read |
|---|
| Ladder main entry (most requests just need this) | |
| How to write each of the six dimensions (symptom → which to add) | |
| Style menu (not defaults) | |
| Platform scene skeletons | WeChat · Xiaohongshu · Douyin/Video Account/Kuaishou |
| Editing discipline (what to change + what to keep, anti-drift) | |
| Parameter tri-state table, , impossible things | |
WeChat Full-Article Illustration Planning: Plan Positions First (free, no image generation)
When an entire article needs several images, first use deterministic rules to pick "which h2 section ends get images" + visual suggestions for each, then generate images one by one:
bash
node scripts/plan-figures.mjs --md 文章.md # 纯本机不接 LLM;--max-figures/--min-chars/--json 可调
Count is tiered by body text length (<1800→3, 1800–3000→4, >3000→5), only picks sections with effective word count ≥160, favoring high-information ones.
It only outputs a plan and doesn't modify files: after generating images per the plan, insert
at the
end of the corresponding h2 section,
then hand to
for rendering and pre-upload.
What This Package Handles and Doesn't
| User says | Who handles |
|---|
| Draw an image / generate image / edit image / text-to-image / image-to-image / key visual / add an illustration / just want a cover | ✅ This package |
| Provided a reference image, want its content preserved (change one spot, add one object) | ✅ Image editing, read |
| Provided a reference image, only want its feel (style, mood) | ✅ Not editing: reverse-engineer seven items per "special entry" and redraw |
| Viral cover templates / same-track cover reference data | ❌ (data retrieval, no image) |
| Give me a cover plan directly | ❌ 's |
| Where to place illustrations in a full article (position planning) | ✅ , see previous section |
| Image pre-upload, cover upload, layout and save as draft | ❌ |
When the
pipeline's "cover / illustration" step needs a new image, it calls this package; image uploading and layout still belong to it.
Gotchas
- Both paths now return PNG (tested after 2026-09 upgrade, ~1–2MB). Previously text-to-image was JPEG —
that was because we explicitly requested jpeg at the time; after switching vendors this parameter is no longer sent, format is decided by upstream.
The script determines the extension by the in the envelope ( will still produce png content),
downstream code assuming by extension will break.
- Reference images are recognized by byte signature, changing the extension won't help. Only png / jpeg / webp are accepted.
- More than 3 reference images will be explicitly rejected by the server (tells you the limit, doesn't truncate for anyone); the script errors before sending.
- Whether editing preserves the original image's tone and layout is luck. Of two tests, one drifted
(see ). After editing, you must compare item by item with the original,
not just look at the edited spot.
- The model likes to add text to the image itself; dense small text is usually gibberish strokes, isolated big text is usually fine.
- 🔴 It also adds semi-transparent watermarks / logos on its own (tested 2026-09-10: images without requested text got an outlined mark in each top corner).
The upstream's appended "no watermark" doesn't stop it. Check the four corners separately during acceptance,
see "Watermark scan" in .
- was de-listed on 2026-08-10, all calls return 503. If the user names it, tell them honestly.
Troubleshooting
| Symptom | Action |
|---|
| How to get it: see dby-gateway/references/protocol.md
, then run |
| Insufficient points, tell user to check balance and how to get them at doubaoya.com account page (points are gifted, not sold), don't retry |
| Key problem, updating the skill won't fix it |
503 CAPABILITY_UNAVAILABLE
| Don't retry, tell the user honestly |
| Request incomplete / timeout | Don't retry (see "Don't retry after failure" above). May have been charged, let the user decide |
| exit code 2 | This package's parameter knowledge is outdated, update references/api-contract.md
based on production |
| exit code 3 | This package's requests go through , which isn't installed. Run to install the full set, or use to point to it |
If you follow this and still can't get around it, or want to complain → you can mention using
to write feedback on the spot (optional, no need to repeat).
Next Steps
| Got | Next |
|---|
| Image is done, need to put it into a WeChat article | (handles image pre-upload, cover upload, and layout) |
| No article body yet, need the whole article too | |
| Want to see same-track viral cover approaches first | (data retrieval) |
| Don't know what style to draw | (the persona and brand facts in the profile are legitimate sources for prompts) |
If you just need one image, stop at this package; don't run any of the above.