Skip to main content

Image Generation Workflows

Build text-to-image pipelines, multi-model comparisons, and image evaluation workflows with Jetty.

Overview

Image generation is Jetty's most popular use case. This guide covers:

  1. Basic text-to-image generation
  2. Multi-model comparison
  3. Image evaluation with LLM judges
  4. Prompt engineering pipelines
  5. Image modification and video generation

Basic Text-to-Image

Workflow: Simple Image Generation

{
"init_params": {
"prompt": "A serene lake with mountains at sunset"
},
"step_configs": {
"generate": {
"model": "black-forest-labs/flux-schnell",
"activity": "replicate_text2image",
"prompt_path": "init_params.prompt",
"output_format": "jpg"
}
},
"steps": ["generate"]
}

Available Models

ModelQualitySpeedBest For
black-forest-labs/flux-schnellGoodFastQuick iterations
black-forest-labs/flux-kontext-proExcellentMediumProduction images
ideogram-ai/ideogram-v2-turboExcellentMediumText in images
google/imagen-4-fastExcellentFastHigh quality
luma/photon-flashGoodFastArtistic styles

Configuration Options

{
"generate": {
"model": "black-forest-labs/flux-schnell",
"activity": "replicate_text2image",
"prompt_path": "init_params.prompt",
"aspect_ratio": "16:9",
"output_format": "jpg",
"num_outputs": 4,
"guidance_scale": 3.5,
"num_inference_steps": 24
}
}

Multi-Model Comparison

Compare outputs from different models on the same prompt.

Workflow: Side-by-Side Comparison

Based on production workflow: t2i-evals

{
"init_params": {
"prompt": "A beautiful landscape with mountains and a lake"
},
"step_configs": {
"flux": {
"model": "black-forest-labs/flux-schnell",
"activity": "replicate_text2image",
"prompt_path": "init_params.prompt"
},
"midjourney": {
"model": "tstramer/midjourney-diffusion:436b051ebd8f68d23e83d22de5e198e0995357afef113768c20f0b6fcef23c8b",
"activity": "replicate_text2image",
"prompt_path": "init_params.prompt",
"guidance_scale": 7.5,
"num_inference_steps": 50
}
},
"steps": ["flux", "midjourney"]
}

Batch Model Comparison

Based on production workflow: t2i-prompt-inversion

{
"init_params": {
"prompt": "A charming cottage in a snow blizzard",
"aspect_ratio": "1:1"
},
"step_configs": {
"ideogram": {
"model": "ideogram-ai/ideogram-v2-turbo",
"activity": "replicate_text2image",
"prompt_path": "init_params.prompt",
"output_format": "jpg",
"aspect_ratio_path": "init_params.aspect_ratio"
},
"imagen4": {
"model": "google/imagen-4-fast",
"activity": "replicate_text2image",
"prompt_path": "init_params.prompt",
"output_format": "jpg",
"aspect_ratio_path": "init_params.aspect_ratio"
},
"luma": {
"model": "luma/photon-flash",
"activity": "replicate_text2image",
"prompt_path": "init_params.prompt",
"output_format": "jpg",
"aspect_ratio_path": "init_params.aspect_ratio"
}
},
"steps": ["ideogram", "imagen4", "luma"]
}

Image Evaluation with LLM Judges

Automatically evaluate generated images for quality, compliance, and content.

Workflow: Multi-Criteria Evaluation

Based on production workflow: llm-judge-plus

{
"init_params": {
"prompt": "A wise owl wearing round glasses",
"model": "black-forest-labs/flux-schnell"
},
"step_configs": {
"generate": {
"activity": "replicate_text2image",
"model_path": "init_params.model",
"prompt_path": "init_params.prompt",
"aspect_ratio": "16:9",
"output_format": "jpg"
},
"ip_risk": {
"model": "gpt-4o",
"activity": "simple_judge",
"items_path": "generate.outputs.images[0].path",
"judge_type": "scale",
"instruction": "There is the potential for an IP Infringement Issue in this image.",
"scale_range": [0, 1],
"model_provider": "openai"
},
"brand_compliance": {
"model": "gpt-4o",
"activity": "simple_judge",
"items_path": "generate.outputs.images[0].path",
"judge_type": "scale",
"instruction": "Evaluate if this image complies with brand guidelines. Check for: proper logo usage, brand color palette adherence, typography consistency, visual style alignment.",
"scale_range": [0, 1],
"model_provider": "openai"
},
"sensitive_content": {
"model": "gpt-4o",
"activity": "simple_judge",
"items_path": "generate.outputs.images[0].path",
"judge_type": "scale",
"instruction": "This image contains sensitive, inappropriate, or potentially harmful content.",
"scale_range": [0, 1],
"model_provider": "openai"
}
},
"steps": ["generate", "ip_risk", "brand_compliance", "sensitive_content"]
}

Understanding simple_judge Outputs

{
"outputs": {
"rating": "0.2",
"explanation": "The image appears to be original artwork...",
"average_score": 0.2,
"model": "gpt-4o"
}
}

Prompt Engineering Pipelines

Enhance user prompts before image generation.

Workflow: Prompt Expansion

Based on production workflow: emd-test-1

{
"init_params": {
"text": "A scientist doing science",
"style": "CGI"
},
"step_configs": {
"expand_prompt": {
"model": "anthropic/claude-3.5-haiku",
"activity": "replicate_text_stream",
"max_tokens": 250,
"prompt_path": "init_params.text",
"system_prompt": "Take simple inputs and transform them into detailed, visually engaging prompts. Add lighting, colors, and surroundings."
},
"generate": {
"model": "black-forest-labs/flux-schnell",
"activity": "replicate_text2image",
"prompt_path": "expand_prompt.outputs.text",
"output_format": "jpg"
}
},
"steps": ["expand_prompt", "generate"]
}

Combining Multiple Prompt Components

Based on production workflow: emd-test-1

{
"init_params": {
"subject": "A scientist",
"color_guidance": "Use white background, green and yellow accents",
"style": "CGI"
},
"step_configs": {
"expand": {
"model": "anthropic/claude-3.5-haiku",
"activity": "replicate_text_stream",
"prompt_path": "init_params.subject",
"system_prompt": "Elaborate with professional, detailed descriptions."
},
"combine": {
"activity": "text_concatenate",
"text_paths": [
"expand.outputs.text",
"init_params.color_guidance"
]
},
"generate": {
"activity": "replicate_text2image",
"prompt_path": "combine.outputs.text"
}
},
"steps": ["expand", "combine", "generate"]
}

Image Modification

Modify existing images with AI.

Workflow: Style Transfer

Based on production workflow: modify_image

{
"init_params": {
"prompt": "Make this a 90s cartoon style",
"image_url": "https://example.com/image.jpg"
},
"step_configs": {
"download": {
"activity": "download_image",
"image_url_path": "init_params.image_url"
},
"modify": {
"model": "black-forest-labs/flux-kontext-pro",
"activity": "replicate_modify_image",
"prompt_path": "init_params.prompt",
"input_image_path": "download.outputs.images[0].path",
"aspect_ratio": "match_input_image",
"output_format": "jpg"
}
},
"steps": ["download", "modify"]
}

Image to Video

Generate videos from images.

Workflow: Text-to-Image-to-Video

Based on production workflow: text2image2video

{
"init_params": {
"prompt": "A scientist holding up a balloon",
"motion": "a zoom out to space"
},
"step_configs": {
"expand": {
"model": "openai/gpt-4",
"activity": "litellm_chat",
"messages_path": "init_params.prompt",
"system_prompt": "Elaborate the prompt with cyberpunk themes."
},
"generate_image": {
"model": "black-forest-labs/flux-schnell",
"activity": "replicate_text2image",
"prompt_path": "expand.outputs.text",
"output_format": "jpg"
},
"animate": {
"activity": "replicate_text2video",
"duration": 3,
"image_path": "generate_image.outputs.images[0].path",
"resolution": "480p",
"prompt_path": "init_params.motion"
}
},
"steps": ["expand", "generate_image", "animate"]
}

Batch Image Generation

Generate images for multiple prompts in parallel.

Workflow: Batch Processing

Based on production workflow: image-tester

{
"init_params": {
"prompts": [
"Time flies when you're having fun",
"A portrait of Paris in Paris",
"A white cat outlined by falling black ink"
]
},
"step_configs": {
"generate_all": {
"activity": "list_emit_await",
"items_path": "init_params.prompts",
"task_reference": {
"task_name": "t2i-evals"
},
"data_mapping": {
"prompt": "{{ $item }}"
}
},
"collect": {
"activity": "extract_from_trajectories",
"trajectory_list_path": "generate_all.outputs.trajectory_references",
"extract_keys": {
"prompt": "t2i_flux.inputs.prompt",
"flux_image": "t2i_flux.outputs.images[0].path",
"midjourney_image": "t2i_midjourney.outputs.images[0].path"
}
}
},
"steps": ["generate_all", "collect"]
}

Best Practices

1. Choose the Right Model

  • Speed: Use flux-schnell for quick iterations
  • Quality: Use flux-kontext-pro or imagen-4 for production
  • Text rendering: Use ideogram for images with text

2. Use Evaluation

  • Always add simple_judge steps for production workflows
  • Check for IP risk, brand compliance, and sensitive content

3. Optimize Prompts

  • Use prompt expansion for better results
  • Combine style guidance with subject descriptions

4. Handle Batches Efficiently

  • Use list_emit_await for parallel processing
  • Collect results with extract_from_trajectories

Next Steps