Automatically generate contextually relevant illustrations for your markdown articles.
You've written a great article, but:
- Finding images takes forever - Searching stock photos or creating custom illustrations is time-consuming
- Generic images don't fit - Stock photos rarely match your specific content
- Consistency is hard - Maintaining visual style across multiple illustrations requires effort
- Quality varies - Hand-picking images leads to inconsistent quality and relevance
Article Illustrator is a multi-stage AI pipeline that:
- Understands your content - Analyzes markdown structure to identify key concepts
- Creates targeted prompts - Generates contextually relevant image descriptions
- Generates images - Uses multiple AI image generation APIs for best results
- Integrates seamlessly - Inserts images at optimal positions in your article
The result: Professional illustrations that enhance your content, generated in minutes.
Prerequisites: Complete the Amplifier setup instructions first.
# Via Makefile (recommended) - creates timestamped output directory
make illustrate INPUT=path/to/article.md
# Direct invocation
uv run python -m scenarios.article_illustrator path/to/article.mdOutput location: By default, creates a timestamped directory in .data/article_illustrator/{article_name}_{timestamp}/ to keep sessions organized and prevent accidental overwrites.
The tool will:
- Analyze your article for illustration opportunities
- Generate targeted image prompts
- Create images using GPT-Image-1 (default)
- Insert images at optimal positions
- Save the illustrated version with all images in the output directory
- Prepare your article - Any markdown file will work:
# My Technical Article
Explaining complex concepts...
## Key Architecture
The system has three main components...
## Implementation Details
Here's how it works in practice...- Run the illustrator:
make illustrate INPUT=my_article.md- Review the output - Find your illustrated article in the output directory with:
- Generated images in
images/folder - Updated markdown with embedded images
- Prompts saved in
prompts.json
- Generated images in
make illustrate INPUT=article.mdWhat happens:
- Identifies key sections needing visual support
- Generates contextually relevant image prompts
- Creates images using GPT-Image-1
- Inserts at optimal positions with proper sizing
make illustrate \
INPUT=article.md \
STYLE="pirate meme style with treasure maps and parrots"What happens:
- Same analysis and placement
- Prompts adapted to pirate theme
- Images generated with consistent style
- Creates fun, themed version of your article
More style examples:
# Minimalist technical diagrams
STYLE="minimalist black and white line art"
# Retro 80s aesthetic
STYLE="retro 80s synthwave with neon colors and grid patterns"
# Watercolor illustrations
STYLE="soft watercolor technical diagrams"make illustrate \
INPUT=article.md \
APIS="gptimage imagen dalle"What happens:
- Generates images using all three APIs
- Saves alternatives as HTML comments
- You can swap between versions easily
- Compare quality and style across APIs
uv run python -m scenarios.article_illustrator article.md --prompts-onlyWhat happens:
- Analyzes content and identifies illustration points
- Generates detailed image prompts
- Saves prompts to JSON (no images generated)
- Preview what will be created before spending money
Custom output location:
# Specify exact output directory
make illustrate INPUT=article.md OUTPUT=custom/output/path/Session resumption (for expensive interrupted operations):
# Resume an interrupted session
make illustrate INPUT=article.md OUTPUT=path/to/existing/session/ RESUME=trueWhat the tool checks when resuming:
- Article path must match
- Style parameters must match (if specified)
- Warns you if parameters don't match and asks for confirmation
Session isolation by default:
- Each run creates a new timestamped directory (e.g.,
.data/article_illustrator/my_article_20251001_153653/) - Sessions organized in centralized
.data/article_illustrator/directory - Prevents accidental overwrites when experimenting with different styles/APIs
- Explicit OUTPUT required to resume or reuse a directory
- Old sessions preserved for comparison
Example workflow:
# First run - creates .data/article_illustrator/article_20251001_150000/
make illustrate INPUT=article.md STYLE="minimalist"
# Second run with different style - creates .data/article_illustrator/article_20251001_150230/
make illustrate INPUT=article.md STYLE="pirate theme"
# Resume first session if interrupted
make illustrate INPUT=article.md OUTPUT=.data/article_illustrator/article_20251001_150000/ RESUME=trueArticle Input
↓
[Content Analysis] ────→ Identify illustration opportunities
↓
[Prompt Generation] ───→ Create contextual image prompts
↓
[Image Generation] ────→ Generate with multiple APIs
↓
[Markdown Update] ─────→ Insert images at optimal positions
↓
Illustrated Article
This tool embodies a structured thinking process:
- Understand - Analyze article structure and identify key concepts that need visual support
- Identify - Find sections where images would add the most value
- Create - Generate detailed, contextually relevant prompts for each illustration
- Execute - Use the best available API to create high-quality images
- Integrate - Insert images at positions that enhance comprehension and flow
This recipe guides the tool through intelligent decision-making at each stage.
- Content Analyzer: Uses LLM to understand article structure and identify illustration opportunities
- Prompt Generator: Creates detailed, contextually relevant image descriptions
- Image Generator: Orchestrates multiple APIs (GPT-Image-1, Imagen-4, DALL-E-3)
- Markdown Updater: Intelligently inserts images with proper formatting
- State Manager: Saves progress after every step (interrupt and resume anytime)
Code handles the structure:
- Pipeline orchestration and flow control
- State management and checkpointing
- File I/O and error handling
- API coordination and retry logic
AI handles the intelligence:
- Understanding article content and structure
- Identifying where images add value
- Creating contextually relevant prompts
- Generating creative, appropriate imagery
This separation means the tool is both reliable (code manages the flow) and creative (AI handles the content).
# Required
INPUT=path/to/article.md # Your markdown article
# Optional
OUTPUT=path/to/output/ # Custom output directory (default: timestamped)
STYLE="description" # Style theme for illustrations
APIS="api1 api2" # Space-separated API list
RESUME=true # Resume existing session (requires OUTPUT)
# Via direct invocation
python -m scenarios.article_illustrator article.md \
--output-dir custom/path/ \
--style "minimalist line art" \
--apis gptimage --apis imagen \
--max-images 3 \
--cost-limit 5.00 \
--resume \
--prompts-onlyImportant notes:
- If OUTPUT not specified, creates
.data/article_illustrator/{article_name}_{timestamp}/ - RESUME flag requires OUTPUT to be specified (tells tool which session to resume)
- Without RESUME, tool creates new session even if OUTPUT directory has existing session
Set environment variables in .env file:
# OpenAI (for content analysis, GPT-Image-1, and DALL-E 3)
OPENAI_API_KEY=your_openai_api_key
# Google (for Imagen 4 via Gemini API)
GOOGLE_API_KEY=your_google_api_keyAll working files are saved to .data/article_illustrator/<timestamp>/:
.session_state.json- Pipeline state for resumeimages/- Generated imagesprompts.json- All generated promptsillustrated_article.md- Final output
output_dir/
├── illustrated_article.md # Updated article with images
├── images/ # Generated images
│ ├── illustration-1-gptimage.png
│ ├── illustration-1-imagen.png
│ └── illustration-1-dalle.png
├── prompts.json # All generated prompts
└── .session_state.json # Resumable session data
Generated markdown uses HTML img tags for responsive sizing:
<img src="./images/illustration-1-gptimage.png" alt="Section Title" width="50%">
<!-- ALTERNATIVES
<img src="./images/illustration-1-imagen.png" alt="imagen version" width="50%">
<img src="./images/illustration-1-dalle.png" alt="dalle version" width="50%">
To use an alternative, replace the main image above.
Generated from: illustration-1
-->Images render at 50% width for optimal readability.
- Estimated costs tracked per image
- Running total maintained in session
- Cost limit enforced if specified
- Summary displayed at completion
Typical costs (2025 pricing):
- Content analysis (GPT-4o-mini): ~$0.01 per article
- Prompt generation (Claude Haiku): ~$0.01 per prompt
- GPT-Image-1: $0.04 per image (1024x1024, auto quality)
- DALL-E 3: $0.04 per image (1024x1024, standard quality)
- Imagen 4: $0.03-$0.04 per image
Example: Generating 5 illustrations costs approximately $0.20-$0.25 total.
Problem: Article too short or lacks visual concepts.
Solution: Ensure article has multiple sections with technical concepts, architecture, or processes that benefit from visualization.
Problem: Environment variables not configured.
Solution: Create .env file in project root with required API keys.
Problem: Session state file not found or corrupted.
Solution: Use --resume flag and ensure output directory is correct. Start fresh without flag if needed.
Problem: Relative paths incorrect.
Solution: Open illustrated markdown from output directory or adjust paths based on your markdown renderer.
- HOW_TO_CREATE_YOUR_OWN.md - Create your own scenario tool
- Amplifier - The framework powering these tools
- Scenario Tools - More tools like this one
This tool demonstrates what's possible when you describe a thinking process to Amplifier:
- Use it - Generate illustrations for your articles
- Experiment - Try different styles and APIs
- Learn from it - See HOW_TO_CREATE_YOUR_OWN.md
- Build your own - Create tools that match your workflow
Built with minimal input using Amplifier - Describe the thinking process, Amplifier handles the implementation. See HOW_TO_CREATE_YOUR_OWN.md for how this was created.