Character & Background Image Generation
Generate reference images with kie.ai nano-banana-pro, host them on imgbb,
and write permanent image_url fields back into the JSON files.
Setup: .env
On first run the script automatically creates a .env template in your project
directory and exits. Open it, fill in your keys, then re-run:
KIE_API_TOKEN=your_kie_api_key_here
IMGBB_API_KEY=your_imgbb_api_key_here
- KIE_API_TOKEN — from kie.ai dashboard → API Keys
- IMGBB_API_KEY — from api.imgbb.com (free account)
- Add
.envto.gitignore— never commit API keys - Real environment variables always take precedence over
.envvalues
A reference copy is at assets/.env.example in this skill's folder.
Prerequisites
characters.jsonandbackgrounds.jsonmust exist (from Skill 2).envin project directory with both keys filled in (auto-created on first run)pip install requests
Running the Script
cd /path/to/your/project
python ~/.claude/skills/generating-character-and-background-images/scripts/generate_images.py
What the script does per image:
- Generate — POST to
jobs/createTask(model:nano-banana-pro, aspect_ratio, resolution:1K) - Poll — GET
jobs/recordInfo?taskId=...untilstate: success; extractresultUrls[0] - Download — save PNG to
./characters/{id}.pngor./backgrounds/{id}.png - Upload to imgbb — POST base64-encoded PNG to
api.imgbb.com/1/upload; get permanent URL - Write back — store imgbb URL as
image_urlincharacters.json/backgrounds.json
Character images: 1:1 aspect ratio (reference sheets) Background images: 16:9 aspect ratio (cinematic wide shots)
If imgbb upload fails, the kie.ai URL is used as fallback (may not be permanent).
Regenerating Specific Images
- Update the
promptfield in the JSON - Delete the existing PNG (e.g.,
./characters/char_001.png) - Re-run the script — it skips existing files, regenerates deleted ones
Important: image_url Fields
After running, each JSON entry has an image_url field containing a permanent
imgbb URL. Skill 5 (generate_videos.py) reads these URLs to generate
composite images — do not delete or overwrite them.
Review Gate (MANDATORY)
After all images are generated, present this EXACTLY:
✅ Image Generation complete.
📋 Summary:
- Character images: [X] generated → ./characters/
[char_001.png: "Name", char_002.png: "Name", ...]
- Background images: [X] generated → ./backgrounds/
[bg_001.png: "Name", bg_002.png: "Name", ...]
- Failed: [X] (list any failures)
- image_url (imgbb) written to: characters.json, backgrounds.json
👉 Please review the generated images. You can:
- Approve all → say "approved" or "proceed"
- Reject specific images → e.g., "regenerate char_001, the hair is wrong"
(update prompt in characters.json, delete the PNG, re-run script)
- Replace images manually → save your PNG as ./characters/char_001.png,
then tell me to upload it to imgbb to get a fresh image_url
⏸️ Waiting for your approval before creating the shot list.
NEVER proceed to the next skill automatically. Wait for explicit approval.