| 4 min read

How I Built a Multi-Agent Image Generator with LangGraph

LangGraph multi-agent image generation Claude brand DNA AI automation

The Brand DNA Image Generator

Most AI image generators produce generic output. They are great for quick visuals, but if you need images that consistently match a brand's identity, tone, colour palette, and aesthetic principles, a single prompt is never enough. You need a system that understands the brand deeply and translates that understanding into image generation prompts.

That is exactly what I built: a multi-agent pipeline using LangGraph that takes a simple brief like "hero image for summer campaign" and produces brand-consistent visuals by orchestrating multiple AI agents, each with a specific role.

Why Multi-Agent?

I tried the single-agent approach first. One prompt, one model, one output. The results were inconsistent. Sometimes the colours were wrong. Sometimes the style drifted. The model had too many things to think about at once: brand guidelines, composition principles, technical image specs, and creative interpretation.

Breaking the task into specialised agents solved this. Each agent focuses on one aspect of the problem, and the orchestration layer ensures they work together coherently.

The Agent Architecture

I built four agents using LangGraph's StateGraph:

1. Brand Analyst Agent

This agent loads the brand DNA profile (a structured JSON document containing colour palettes, typography rules, tone descriptors, visual motifs, and do/don't guidelines) and extracts the constraints relevant to the current brief.

2. Creative Director Agent

Takes the brief and the brand constraints, then generates three creative concepts. Each concept includes a composition description, mood, lighting direction, and colour emphasis. This agent uses Claude Sonnet for its strong creative reasoning.

3. Prompt Engineer Agent

Translates the chosen creative concept into optimised prompts for the image generation model. This is more technical than it sounds. Different models respond to different prompt structures, and this agent knows the syntax that produces the best results.

4. Quality Reviewer Agent

After image generation, this agent evaluates the output against the original brand DNA profile. It scores alignment on colour accuracy, style consistency, and brief adherence. If the score is below threshold, it sends the task back with specific feedback.

from langgraph.graph import StateGraph, END

def build_brand_image_graph():
    workflow = StateGraph(BrandImageState)
    
    workflow.add_node("brand_analyst", brand_analyst_node)
    workflow.add_node("creative_director", creative_director_node)
    workflow.add_node("prompt_engineer", prompt_engineer_node)
    workflow.add_node("generate_image", image_generation_node)
    workflow.add_node("quality_review", quality_review_node)
    
    workflow.set_entry_point("brand_analyst")
    workflow.add_edge("brand_analyst", "creative_director")
    workflow.add_edge("creative_director", "prompt_engineer")
    workflow.add_edge("prompt_engineer", "generate_image")
    workflow.add_conditional_edges(
        "quality_review",
        lambda state: "prompt_engineer" if state["score"] < 0.8 else END
    )
    workflow.add_edge("generate_image", "quality_review")
    
    return workflow.compile()

Brand DNA Profiles

The brand DNA is stored as structured JSON. Here is a simplified example of what one looks like:

{
  "brand_name": "ExampleCo",
  "colour_palette": {
    "primary": ["#1a1a2e", "#16213e"],
    "accent": ["#e94560"],
    "neutral": ["#f5f5f5", "#333333"]
  },
  "visual_style": "minimal, geometric, high contrast",
  "tone": "confident, modern, approachable",
  "avoid": ["busy patterns", "warm filters", "handwritten fonts"]
}

This profile acts as the source of truth that every agent references. The Brand Analyst agent interprets this for each specific brief, pulling out only the relevant constraints.

LangGraph State Management

LangGraph's state management was the main reason I chose it over a simple chain. The state accumulates context as it moves through agents:

  • After the Brand Analyst: state contains extracted brand constraints
  • After the Creative Director: state contains three concepts with rationale
  • After the Prompt Engineer: state contains the final generation prompt
  • After Quality Review: state contains scores and feedback, potentially triggering a loop

The conditional edge after quality review is powerful. If an image does not meet brand standards, the system loops back to the Prompt Engineer with specific feedback, refining the prompt. In practice, most images pass on the first attempt, but the retry loop catches the 15 to 20 percent that drift off-brand.

Results

Comparing the multi-agent approach to single-prompt generation:

  • Brand consistency score: improved from 62% to 91% (measured by the Quality Reviewer agent against brand DNA)
  • Revision requests from stakeholders: dropped by roughly 70%
  • Time to produce on-brand visuals: reduced from 45 minutes (manual iteration) to under 2 minutes

Handling Edge Cases

Not every brief produces a good result on the first pass. I encountered several edge cases during development: briefs that were too vague for the Creative Director to work with, brand DNA profiles that had contradictory guidelines, and image generation prompts that produced technically correct but aesthetically poor results. For vague briefs, I added a clarification step where the Brand Analyst agent asks for more detail before proceeding. For contradictory guidelines, the system flags the conflict and asks for human resolution. These guardrails took extra development time but made the system genuinely reliable for production use.

Performance and Cost

The full pipeline takes about 90 seconds to produce a final approved image, including any retry loops. Most of that time is spent on image generation. The AI orchestration steps (brand analysis, creative direction, prompt engineering, quality review) collectively take about 15 seconds. The total API cost per image is roughly 5 to 8 pence, which is negligible compared to the time savings from not having a human iterate manually through dozens of prompts.

Key Takeaways

Building this system taught me that multi-agent architectures shine when a task has clearly separable concerns that require different types of reasoning. The Creative Director needs divergent thinking. The Prompt Engineer needs technical precision. The Quality Reviewer needs evaluative judgement. No single agent does all of these well.

LangGraph made the orchestration straightforward, especially the conditional routing for quality control loops. If you are building any system where output quality matters and you can define clear evaluation criteria, a review-and-retry loop is one of the highest-impact patterns you can implement.