Quality options: standard, hd
Doubao Image Generation SkillThis skill integrates the Volcano Engine Doubao Seedream 4.5 API to quickly generate high-quality accompanying images for scenarios such as WeChat official account articles, technical blogs, and presentations.
⚡ Quick Execution Guide (Important)
Prerequisite Checks
Before generating images, please confirm:
-
DOUBAO_API_KEY is configured
- Open the settings panel → API Configuration
- Confirm it shows "Doubao API Key: Configured"
-
Output directory has been created
- Check command:
dir assets\images(Windows) orls assets/images(Linux/Mac) - If it does not exist, use
run_commandto create it:mkdir -p assets/images
- Check command:
- Working directory is correct
- You should currently be in the WeChat official account project directory (such as
D:\公众号试验\文章标题\)
- You should currently be in the WeChat official account project directory (such as
Execution Method
Use the run_command tool to execute the command(recommended):
python resources/skills/image-generation/scripts/doubao_image_gen.py --prompt "技术架构图,展示微服务系统结构" --size "1792x1024" --quality "hd" --output "assets/images/01-微服务架构.png"
Complete Workflow:
- Use the
read_filetool to read the article content - Analyze the images that need to be generated
- Use the
run_commandtool to execute the above command - Confirm that the returned information contains "Successfully wrote to"
- Use the
write_filetool to update the article and insert image references
Frequently Asked Questions
Q: It prompts "DOUBAO_API_KEY environment variable is not set" A: You need to configure the Doubao API Key in the settings panel
Q: Where are the generated images?
A: They are saved in the specified output path, such as assets/images/01-xxx.png
Q: How do I test whether the API Key is configured successfully? A: Run the following command to test:
python resources/skills/image-generation/scripts/doubao_image_gen.py --prompt "测试" --output test.png
🚀 Quick Start
Basic Invocation
from image-generation.scripts.doubao_image_gen import DoubaoImageGenerator
# 初始化
generator = DoubaoImageGenerator(api_key="your_api_key")
# 生成图像
result = generator.generate_image(
prompt="技术架构图,展示微服务系统结构",
size="1792x1024", # 16:9横版
quality="hd"
)
print(result["url"]) # 输出图像URL
Command-Line Usage
python .claude/skills/image-generation/scripts/doubao_image_gen.py \
--prompt "技术架构图,展示微服务系统结构" \
--size "1792x1024" \
--output "architecture.png"
📋 Parameter Description
size (image size)
| Size | Ratio | Applicable Scenarios |
|---|---|---|
1024x1024 |
1:1 | Social media, square accompanying images |
1792x1024 |
16:9 | Blog covers, horizontal charts |
2560x1440 |
16:9 | High-definition horizontal images (recommended ⭐) |
1024x1792 |
9:16 | Mobile wallpapers, vertical posters |
⚠️ Important Note:
- The Doubao API requires images to be at least 3,686,400 pixels
- The images generated by this skill are in a 16:9 ratio,and cannot be used directly for WeChat official account covers
- WeChat official account covers require a 2.35:1 ratio (900×383 or 1080×460)
- If you need a WeChat official account cover, please use
cover-generatorskill- cover-generator will first generate a 16:9 base image, then intelligently crop it to 2.35:1
quality (image quality)
standard: Fast generation, suitable for previews (default)hd: High-quality output, suitable for publishing
model (model selection)
doubao-seedream-4-5-251128: Latest 4.5 version (recommended)doubao-seedream-4-0-250828: 4.0 version
🎨 Prompt Templates
This skill provides a rich library of prompt templates, located at references/prompt-templates.md:
Technical Chart Templates
- Architecture Diagram: Shows system layering and component relationships
- Flowchart: Shows business processes and step order
- Comparison Table: Compares the differences between two technologies/solutions
- Data Chart: Display performance metrics and statistical data
Article illustration templates
- WeChat cover: 2.35:1 horizontal format (consider sharing crop, keep key content centered)
- Tech cover: tech-style gradient background + theme icon
- Concept explanation: step-by-step diagram of technical principles
- Code demo: IDE-style code editor interface
Usage: see references/prompt-templates.md
🎨 Style system (new feature)
This skill now supportsXiaohongshu style + WeChat Official Account specificationsstyle template system, automatically generating high-quality covers and illustrations.
14 preset styles
Existing styles (5 types)
| Style code | Style name | Applicable scenarios | Color characteristics |
|---|---|---|---|
tech |
Professional tech | Technical articles, AI topics, programming tutorials | Deep blue → purple gradient, white text |
fresh |
Fresh and lively | Life sharing, study notes, growth records | Mint green → warm yellow gradient, dark green text |
minimal |
Minimalist | Philosophical thinking, in-depth viewpoints, minimalism | Light gray-white background, dark gray text |
warm |
Warm and healing | Emotional articles, growth reflections, life stories | Warm yellow → pink gradient, dark brown text |
business |
Business professional | Business analysis, data reports, market research | Deep blue background, white text |
New styles (9 types, from Baoyu)
| Style code | Style name | Applicable scenarios | Color characteristics |
|---|---|---|---|
elegant |
Elegant and refined | Business analysis, leadership content, professional services | Warm cream background, coral accent |
bold |
High-contrast impact | Opinion articles, important reminders, warning content | Black background, bright red/yellow text |
playful |
Lively and fun | Tutorial guides, light content, beginner tutorials | Light cream background, mint green accent |
nature |
Natural and organic | Environmental health, nature themes, sustainable development | Sand beige background, forest green text |
sketch |
Hand-drawn sketch | Brainstorming, creative process, concept design | Off-white background, pencil gray text |
notion |
Notion minimalist lines | Knowledge sharing, concept explanation, productivity tools | Pure white background, black minimalist lines |
Using the style system
Method 1: Python code
from image_generation.scripts.style_prompt_builder import build_prompt
# 生成专业科技风格封面提示词
prompt = build_prompt(
title="智谱上市579亿",
style="tech",
scene_type="cover",
subtitle="GLM-4.7实测"
)
print(prompt)
# 自动匹配风格
prompt = build_prompt(
title="我的学习笔记和成长感悟",
style="auto", # 自动匹配为 fresh 风格
scene_type="cover"
)
Method 2: Command line (cover-generator)
# 使用专业科技风格
python .claude/skills/cover-generator/scripts/cover_generator.py \
--use-style \
--title "智谱上市579亿" \
--style tech \
--subtitle "GLM-4.7实测"
# 自动匹配风格
python .claude/skills/cover-generator/scripts/cover_generator.py \
--use-style \
--title "我的学习笔记" \
--style auto
Style system features
✅ Integrates the advantages of Xiaohongshu style
- Clear text hierarchy and whitespace
- High-contrast color scheme to ensure readability
- Exquisite visual design
✅ Follows WeChat Official Account special requirements
- 2.35:1 horizontal ratio
- Central 60% safe area design
- Dual-scenario optimization (cover + sharing card)
- Anti-cropping design
✅ Automatic style matching
- Intelligently recommend styles based on content keywords
- Technical keywords → tech
- Lifestyle keywords → fresh
- Emotional keywords → warm
- Business keywords → business or elegant
- Opinions/Warnings → bold
- Tutorials/Guides → playful
- Eco-friendly/Health → nature
- Brainstorming/Creativity → sketch
- Knowledge sharing/Concepts → notion (default)
Complete example
Reference documentation:
references/style-templates.md- Complete definitions of 5 stylesreferences/combination-examples.md- 10 complete prompt examplesreferences/xiaohongshu-style-guide.md- Xiaohongshu style guidelinesreferences/wechat-cover-guide.md- WeChat Official Account cover design guide
🎯 Scenario Selection Guide
Scenarios suitable for AI image generation ✅
Marketing and promotion(AI excels ⭐⭐⭐⭐⭐)
- Social media posters (Xiaohongshu/Weibo/Moments style)
- Event promotional posters (holidays, promotions, new product launches)
- Banner ads (website banners, app splash screens)
- Product display images (scenario-based product rendering)
Creative design(AI excels ⭐⭐⭐⭐⭐)
- Logo and icon design (brand identity, functional icons)
- Scene illustrations (story backgrounds, concept art)
- Background textures (gradient backgrounds, abstract patterns)
Education and training(AI is fairly good ⭐⭐⭐)
- Mind maps (keyword-only version, text should not be excessive)
- Instructional illustrations (scenario-based diagrams, text <50 characters)
- Knowledge cards (concept cards, famous quotes)
- Timelines (historical events, project milestones)
Content creation(AI excels ⭐⭐⭐⭐⭐)
- Article covers (tech-style gradients, theme icons)
- Concept diagrams (visualization of abstract concepts)
- Background images (atmospheric background images)
Scenarios not suitable for AI image generation ❌
Precise technical charts(professional tools recommended)
- Comparison tables containing large amounts of text → Excel/PPT/Numbers
- Complex code displays → IDE screenshots (VS Code/IntelliJ)
- Precise data charts → ECharts/Excel/Tableau
- Detailed technical architecture diagrams → Draw.io/ProcessOn/Lucidchart
Reason: Current AI models have limited text rendering capabilities and may produce typos, blurry text, or chaotic layouts.
Scenario selection decision tree
1. 需要生成图像?
↓ 是
2. 图像主要用途?
├─ 营销推广 → ✅ 使用AI生图(优先级最高)
├─ 创意设计 → ✅ 使用AI生图(优先级最高)
├─ 教育培训 → ⚠️ 谨慎使用(文字少则可用)
├─ 内容创作 → ✅ 推荐AI生图
└─ 精确技术图表 → ❌ 使用专业工具
↓
3. 图像中文字内容?
├─ 几乎没有文字 → ✅ 强烈推荐AI
├─ 少量标题/标语 → ✅ 推荐AI
├─ 中等文字量 → ⚠️ 可尝试AI,需验证效果
└─ 大量文字/数据 → ❌ 不推荐AI
Quick reference table
| Scenario type | AI image generation suitability | Recommended tool | Recommended size |
|---|---|---|---|
| Social media poster | ⭐⭐⭐⭐⭐ | AI image generation | 1024×1024 |
| Event promotional poster | ⭐⭐⭐⭐⭐ | AI image generation | 1024×1792 |
| Banner ad | ⭐⭐⭐⭐⭐ | AI image generation | 1792×1024 |
| Logo design | ⭐⭐⭐⭐ | AI image generation | 1024×1024 |
| Scene illustration | ⭐⭐⭐⭐⭐ | AI image generation | 1792×1024 |
| Background texture | ⭐⭐⭐⭐⭐ | AI image generation | 1792×1024 |
| Article cover | ⭐⭐⭐⭐⭐ | AI image generation | 1792×1024 |
| Mind map | ⭐⭐⭐ | XMind → AI-assisted | 1792×1024 |
| Teaching illustrations | ⭐⭐⭐ | AI image generation (minimal text) | 1792×1024 |
| Technical architecture diagram | ⭐⭐ | Draw.io | Any |
| Code display | ⭐ | IDE screenshot | Any |
| Data comparison table | ⭐ | Excel/PPT | Any |
Recommended combination strategies
Best practices: AI + professional tool combination
营销海报:AI生成底图 → Canva添加文字
Logo设计:AI生成创意方向 → Figma精修
技术文档:AI生成素材 → Draw.io组合
数据报告:AI生成配色灵感 → ECharts实现
💡 Best practices
Prompt engineering principles
-
Basic formula: subject + scene + style
技术架构图 + 微服务系统结构 + 扁平化科技风格 -
Advanced formula: subject description + scene description + style definition + camera language + atmosphere words + detail modifiers
技术架构图,展示微服务的3层架构 从上到下依次是:API网关、业务服务、数据层 使用蓝色和橙色配色方案 箭头表示数据流向 扁平化设计,科技感 白色背景,16:9比例 -
Key principles:
- ✅ Specific description ("blue gradient card" > "nice-looking card")
- ✅ Clear structure ("split into 4 steps from left to right" > "multiple steps")
- ✅ Include style ("flat tech style" > "modern style")
Cost optimization suggestions
- Development stage: use
standardquality and1024x1024size - Batch generation: test a single image first, then batch generate after satisfaction
- Smart caching: similar prompts can reuse results
- API Key management: use environment variables
DOUBAO_API_KEY
🔗 Integration methods
Working with wechat-workflow
In the official account article creation workflow, this skill can serve as:
-
Automatic image generator
- Read
02_文章内容.md - Identify image placeholders
![配图:xxx] - Generate corresponding images based on the context
- Automatically replace placeholders
- Read
-
Manual image tool
- Users describe image needs
- Generate multiple versions for selection
- Download and insert into the article
Batch generation process
prompts = [
"迁移流程图:DeepSeek → GLM",
"技术指标图表:GLM-4.7性能数据",
"对比表格:GLM vs DeepSeek"
]
results = generator.batch_generate(
prompts=prompts,
size="1792x1024",
quality="hd"
)
# 批量下载到assets目录
for i, result in enumerate(results):
generator.download_image(
result["url"],
f"assets/images/0{i+1}_配图.png"
)
📚 Reference documentation
- Prompt template library:
references/prompt-templates.md - Best practices guide:
references/best-practices.md - Volcano Engine official documentation:https://www.volcengine.com/docs/82379/1541523
⚙️ Environment configuration
Install dependencies
pip install openai requests
Configure API Key
Method 1: Environment variables (recommended)
export DOUBAO_API_KEY="your_api_key"
Method 2: Hardcode in code
api_key = "your_api_key" # 不推荐生产环境
🔧 Troubleshooting
Common issues
Q1: Generation failed, showing "API key invalid"
- Check whether
api_keyis correct - Confirm the API key has sufficient balance
Q2: Generation is slow
- Try using
quality="standard" - Check the network connection
Q3: Generated results do not meet expectations
- Optimize the prompt and add more details
- Refer to examples in the prompt template library
- Try adjusting the
sizeparameter
Q4: Image size is too large
- Use tinypng.com or ImageMagick to compress
- Choose a smaller size when generating
🔄 Alternatives when the API fails
When the Doubao API is unavailable, you can use the following alternatives:
Option 1: Use cover-generator (recommended ⭐)
Use cases: Need to generate WeChat official account covers and share cards
Advantages:
- ✅ Supports solid color and gradient backgrounds (no API required)
- ✅ Built-in 5 preset styles (tech, fresh, minimal, warm, business)
- ✅ Automatically generates text titles
- ✅ Smart cropping and share card synchronization
How to use:
生成封面:AI技术趋势,使用专业科技风格
Option 2: Online design tools
Canva - https://www.canva.cn
- ✅ Free use of a large number of templates
- ✅ Supports WeChat official account cover dimensions (900×383)
- ✅ Online editing, no download required
- ✅ Chinese interface, easy to use
Gaoding Design - https://www.gaoding.com
- ✅ Professional WeChat official account cover templates
- ✅ Supports team collaboration
- ✅ Provides a design element library
Chuangkit - https://www.chuangkit.com
- ✅ Massive free templates
- ✅ Quick editing and export
- ✅ Supports multiple design scenarios
Option 3: Use local image tools
Pillow(Python)
from PIL import Image, ImageDraw, ImageFont
# 创建渐变背景
img = Image.new('RGB', (1792, 1024), color='#4A90E2')
draw = ImageDraw.Draw(img)
# 添加标题
font = ImageFont.truetype('arial.ttf', 80)
draw.text((100, 400), "AI技术趋势", fill='white', font=font)
img.save('cover.png')
Figma / Sketch
- ✅ Professional design tools
- ✅ Precise layout control
- ✅ Reusable templates
Option 4: Use other AI image generation services
Midjourney
- ✅ Good artistic results
- ✅ Active community support
- ❌ Requires a paid subscription
Stable Diffusion
- ✅ Open source and free
- ✅ Can be deployed locally
- ❌ Complex configuration
DALL-E 3
- ✅ Strong text rendering capability
- ✅ ChatGPT integration
- ❌ Requires payment
Option selection recommendations
| Scenario | Recommended option | Reason |
|---|---|---|
| WeChat official account cover | cover-generator | No API required, built-in styles |
| Marketing poster | Canva | Rich templates, easy to use |
| Technical charts | Figma | Precise control, professional output |
| Rapid prototyping | Pillow | Code generation, customizable |
| Artistic creation | Midjourney | Best results |
How to determine whether the API is available
Run the following test:
python .claude/skills/image-generation/scripts/doubao_image_gen.py \
--prompt "测试" \
--output test.png
If you see "Generation failed" or an API error, it is recommended to use an alternative option.
Last updated:2026-01-11 Skill version:v1.0 Model version:doubao-seedream-4-5-251128