Universal image generation
This is a universal image-generation capability. Never assume the supplied content is finance-related. Determine the subject and visual style from the actual input.
When to invoke
Use the image agent whenever the user asks for visual assets, illustrations, carousel art, or images based on supplied content. It is not coupled to a research or publishing workflow.
Supported input
- Plain text and Markdown.
- JSON objects and arrays, including serialized DialogueScript and InstagramPost content.
- Individual slides/scenes and multi-section documents.
- Existing
visual_promptfields, which should be reused as context.
Plan and generate
Run commands from the image-generation-agent project directory. Always
preview a plan first when requested or when generation cost/volume warrants it:
python -m src.image_agent.cli --input content.json --dry-run
The dry run analyzes the actual topic with the configured LLM and prints the domain, sections, style, aspect ratio, and full prompts; it does not contact the image provider or save images. To generate:
python -m src.image_agent.cli --input content.json
python -m src.image_agent.cli --input content.md --aspect-ratio 4:5
python -m src.image_agent.cli --input content.json --style cinematic \
--images-per-section 2 --output output/custom
# Retry failed images with their saved prompts, without re-analysis
python -m src.image_agent.cli \
--retry output/images/generated/topic/generation_manifest.json
The plan determines a content-appropriate number of images, bounded by the configured maximum. For slides/scenes, keep ordering and a consistent style across the series. Use existing visual prompts as source material. Do not add facts beyond the input. Exact text should be overlaid with Pillow, never delegated to the image model.
Report and failures
Images and generation_manifest.json are saved under the requested output
directory, in a unique content-slug folder. Report the exact output path,
number of successful/failed images, and manifest path. Check the manifest
before reporting completion.
If analysis fails, report the configured LLM API error. If image generation fails, report
the provider error and failed image number; do not imply an image was produced
or silently switch providers. Cloudflare generation requires
CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN. Previously generated files
are never overwritten. Retry failures with --retry <generation_manifest.json>
so successful images are skipped and the original prompts are reused.